Unable to login to docker via Ubuntu 18.04.5 LTS - docker

I am having an issue on login to docker from my Ubuntu 18.04.5 LTS
This is the command I run to login docker
sudo docker login -u myname -p mypass
This is the error I've got
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
I did searches on google and seems it is not quite a common issue to everyone.
This is my docker version
Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:45:36 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:44:07 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Basically, there are what I have done so far:
run sudo docker run hello-world to verify that my docker is runner properly
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
run sudo vi ~/.docker/config.json to add "HttpHeaders
{
"auths": {},
"HttpHeaders": {
"User-Agent": "Docker-Client/19.03.12 (linux)"
}
}
run sudo vi /etc/docker/daemon.json to add dns then reload daemon and restar docker
{
"dns": ["8.8.8.8","8.8.4.4" ]
}
run curl https://registry-1.docker.io/v2/ and sure enough I've got this
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
As people were talking about proxy server, I also did a test run curl https://google.com aand get respons, does it mean that my server is not reside behind a proxy?
Unfortunately, after try several combinations of above solutions, I'm still not able to login to docker.
Does anyone has any advice?

Related

Timeout exceeded when trying to pull hello-world image on wsl2 windows10

I install wsl2 (ubuntu 20.04) on my windows system and I am having troubles with docker. I am not able to run simple hello-world image because I get following error:
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
I configured resolv.conf by adding nameserver 8.8.8.8 and 8.8.4.4 because I've read that this helped some people but it didn't work for me.
My version of docker:
Version: 20.10.9
API version: 1.41
Go version: go1.16.8
Git commit: c2ea9bc
Built: Mon Oct 4 16:08:29 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.9
API version: 1.41 (minimum version 1.12)
Go version: go1.16.8
Git commit: 79ea9d3
Built: Mon Oct 4 16:06:37 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.11
GitCommit: 5b46e404f6b9f661a205e28d59c982d3634148f8
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
I tried to restart docker - sudo service docker restart but it also didn't help.
I am out of ideas how to fix this. Can anybody help me with this issue?
This problem happend to me too.
I found this article helpful.
https://serverfault.com/questions/908141/docker-pull-tls-handshake-timeout
It provides temporary solution, like docker pull ${IMAGE} separately.
It helped me.
P.S. This error is not common, it may be caused from time to time, so don't spend too much time on it :)
I started getting this error on a Centos 7 server. The cause was wrong proxy settings: the network team of my company removed the need for a proxy and I checked that no HTTPS_PROXY env variable was set on the server but in my case the proxy setting for Docker was in /etc/systemd/system/docker.service.d/http-proxy.conf as described in this page.
BTW, I also tried updating Docker but yum didn't work either: it has its own proxy settings in /etc/yum.conf.

Why does docker stop all containers after a while?

We've installed Docker CE on Ubuntu 20.04 LTS, and it used to work as expected, but since recently, I've noticed that all running containers are stopped after a while (~ 1-2 days).
The very same containers show no problems on an Ubuntu 16.04 LTS installation, so I assume the problem lies within the OS or docker.
I've checked the docker log using
sudo journalctl -xu docker.service
but it shows me only the startup entries. There is no entry that would give a hint about why the containers have been stopped.
When I check the stopped containers using
docker ps -a
the status is: Exited (255) 36 hours ago
If I look at the container log using
docker logs <containername>
there is no problem or error reported either. The log simply ends. Only in our LDAP container, I see
613c0916 daemon: shutdown requested and initiated.
613c0916 slapd shutdown: waiting for 0 operations/tasks to finish
*** Killing all processes...
I've searched the internet for possible causes and found reports about an OS update problem in https://forums.docker.com/t/mysterious-docker-engine-shutdown/101193 and https://bugs.launchpad.net/ubuntu/+source/containerd/+bug/1870514
I've updated Ubuntu using
sudo apt update && sudo apt upgrade -y
but the problem continues to happen.
How can I find out what is going on?
Version info:
Client: Docker Engine - Community
Version: 20.10.8
API version: 1.40
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:54:27 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server:
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: bd33bbf
Built: Fri Feb 5 15:58:24 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit:
docker-init:
Version: 0.18.0
GitCommit: fec3683
Turned out that the update would simply not cure the problem.
I had to turn off the auto-update feature:
$ sudo dpkg-reconfigure unattended-upgrades
After that, I also removed the snap install of Docker, and re-installed it the "old-fashioned" way according to the Docker installation docs because of the problem described here.

Docker not logging into local repository

I have just set up a local VM running Nexus. I have configured a Docker repository on port 5000. I have a separate VM running Docker. I have configured the repository in /etc/docker/daemon.json as so:
{
"insecure-registries": ["192.168.0.5:5000", "nexus:5000"]
}
I then restarted the Docker service. and I have run the command:
docker login 192.168.0.5:5000
I am prompted for a username and password, and when I enter them it returns with::
Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password
I have checked the Docker documentation, and other online resources on how to login to a local docker repository, but I have exactly the same configuration and it just always throws this error.
If I try to push my image, it attempts to contact the local repository, but it complains there are no credentials (as well it should):
[root#docker repo]$ docker tag repo 192.168.0.5:5000/repo
[root#docker repo]$ docker image push 192.168.0.5:5000/repo
Using default tag: latest
The push refers to repository [192.168.0.5:5000/repo]
7d5760c4aa8d: Preparing
3102e53269f4: Preparing
2f140462f3bc: Preparing
63c99163f472: Preparing
ccdbb80308cc: Preparing
no basic auth credentials
Am I missing something?
I am experiencing the same but only with MacOS "Docker Desktop" installations. On Windows it's working as expected.
Client:
Cloud integration: 1.0.17
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:55:20 2021
OS/Arch: darwin/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Fri Jul 30 19:52:31 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b63
docker-init:
Version: 0.19.0
GitCommit: de40ad0
As I am trying to login to a local registry (using Artifactory) I've checked the reverse proxy's logs. The MacOS client doesn't even try to reach the local registry.

Why does FROM registry.hub.docker.com/library/centos:centos7 fail in my docker build?

The following line in my Dockerfile:
FROM registry.hub.docker.com/library/centos:centos7
fails with the following error:
Sending build context to Docker daemon 1.664MB
Step 1/17 : FROM registry.hub.docker.com/library/centos:centos7
Get https://registry.hub.docker.com/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
I am running behind a proxy and I tried to follow the instructions on this website, but still no success (same error). So I have a file in my ~/.docker/config.json that pretty much looks like what the link says, and I inserted my internal proxy IP address information. However, I still get the same "request canceled" error message shown above.
Here is some information about my CentOS 7 system:
Linux localhost.localdomain 3.10.0-1160.15.2.el7.x86_64 #1 SMP Wed Feb 3 15:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
docker version
Client: Docker Engine - Community
Version: 20.10.5
API version: 1.41
Go version: go1.13.15
Git commit: 55c4c88
Built: Tue Mar 2 20:33:55 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.5
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 363e9a8
Built: Tue Mar 2 20:32:17 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.4
GitCommit: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
runc:
Version: 1.0.0-rc93
GitCommit: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
docker-init:
Version: 0.19.0
As richyen said, the correct image is centos:7 and should make it work.
You are speaking about a proxy : the method you used to set a proxy up works, but if your system uses systemd (which is centos7 case I think) you should use this method to set your docker proxy up. I had a lot of troubles with that in the past.

Docker Hello-world fails with "no such file or directory"

OS: Ubuntu cinammon 20.04
I followed the directions from here: docker documentation
When I get to the step to run the Hello-world image.
$ sudo docker run hello-world docker: Error response from daemon: open /var/lib/docker/aufs/layers/9cd449051217b6dc5c24c81e1a02ef897eeb90ee62421d6a227ddfbeddc2b70c-init: no such file or directory. See 'docker run --help'.
`
I've stopped and started the daemon.
sudo service docker stop sudo service docker start
and
systemctl restart docker
The image exists locally per:
$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest bf756fb1ae65 6 months ago 13.3kB
I've been Googling this and getting nowhere. I've seen other places where restarting the daemon fixes it, but I'm just not that lucky.
Any ideas??
More info:
$ sudo docker version
Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:45:44 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:44:15 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683

Resources