I'm trying to run a basic image as described in the Docker tutorial:-
docker --version
Docker version 1.9.0, build 76d6bc9
docker run -t -i ubuntu:14.04 /bin/bash
but it is reporting:
Error while pulling image: Get https://index.docker.io/v1/repositories/library/ubuntu/images: x509: certificate is valid for FG3K6C3A15800002, not index.docker.io
I'm behind a corporate firewall, so have set http_proxy and https_proxy env variables appropriately. The server itself is Ubuntu 14.04 LTS.
I've read various posts about clock settings etc, but these seem OK.
Has anyone any ideas?
Even though you state having set your proxy variable, make sure to try this full set of proxy variables n your /etc/default/docker:
export "HTTP_PROXY=http://<user>:<password>#<proxy.company.com>:<port>"
export "HTTPS_PROXY=http://<user>:<password>#<proxy.company.com>:<port>"
export "http_proxy=http://<user>:<password>#<proxy.company.com>:<port>"
export "https_proxy=http://<user>:<password>#<proxy.company.com>:<port>"
export "NO_PROXY=.company.com,.sock,localhost,127.0.0.1,::1"
export "no_proxy=.company.com,.sock,localhost,127.0.0.1,::1"
If that doesn't solve the issue, upgrade docker to the latest 1.10.1.
Note: docker machine issue 531 mentions docker-machine provision as a workaround.
Update 2021 on issue 531
I had the same exact issue just now and apparently it was fixed by resetting docker to factory settings and enabling the Kubernetes cluster again.
EDIT: I managed to reproduce the fix on a second machine. The exact steps in my case were:
start Docker Desktop
update to 3.2.1 -> immediately after this another updated was available to 3.2.2
update to 3.2.2
enable Kubernetes cluster -> wait until the error appears
right click on Docker in the System Tray -> choose Troubleshoot
click Reset to factory defaults -> wait until the reset is finished
right click on Docker in the System Tray -> choose Quit Docker Desktop
open Docker Desktop again
select only Enable Kubernetes
Related
Here is my setup:
Windows 10 PRO - build 19041.153 - insider program - slow ring
Ubuntu 18.04LTS subsystem in WSL2 mode
Docker for desktop 2.2.0.4 - enabled WSL2 integration with my Ubuntu subsystem
I am currently forced to use Windows for development, so I became a
Microsoft insider member and installed ubuntu with WSL2 mode. Docker desktop supports integration for WSL2, so I tried it...
For a week it worked flawlessly. Today after a PC restart, I can't get docker running again. Ubuntu can see the injected binaries from Docker desktop, but it can't connect to windows hosted docker daemon anymore.
When I call in the WSL terminal docker info it returns
$ docker info
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
or with docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
What I've tried already:
expose daemon without TLS with envs like DOCKER_HOST=localhost:2375, DOCKER_HOST=tcp://localhost:2375, DOCKER_HOST=127.0.0.1:2375, DOCKER_HOST=tcp://127.0.0.1:2375 => same result
uninstall Docker desktop and install previous version
turn off windows firewall
I really, really need this to work. Thanks for any ideas. Weirdest thing is it worked yesterday and I didn't make any changes in system from then...
I know this may be outdated for the present question, but this should save us precious time, especially when Windows 20H1=2004 is going to Production this month (May 2020).
Operating System Version: Windows 10 Education (Same as Enterprise and a superset of Pro).
Version: 2004
Build (Version OS): 19041.264
Others: Windows Feature Experience Pack 120.2202.130.0.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shell: WSL Terminal
First, I have installed WSL v1 previously, then executed the procedure to upgrade to WSLv2, and this error shows up: "ERROR: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?".
Second, to fix that error, I followed instructions stated here: Link, and it worked.
Third, after some tests I think the missing change in the upgrade, was removing the DOCKER_HOST variable from shell's start script.
SUMMARY: In my case, the procedure for a permanent fix should be the following STEPs:
1. Test if it's your case unsetting DOCKER_HOST variable (See image below).
2. If the error disappears with previous step, then time to fix changes by removing the setting of the DOCKER_HOST variable in the shell's start script (In my case was *$HOME/.bashrc*).
Commented this out:
#export DOCKER_HOST=tcp://localhost:2375
#export DOCKER_BUILDKIT=1
NOTE: Also include DOCKER_BUILDKIT.
3. Close and open the Terminal.
Test in Step 1:
Good luck!!
If it helps anyone else that is having this issue, for me it turned out that my subsystem was suddenly (and "on its own") ticked off in docker's RESOURCES > WSL INTEGRATION settings.
On the Docker Desktop app I had to manually enable my distro integration under
Settings > Resources > WSL Integration
I had installed Docker for Windows, as recommended, to use it with WSL 2 and that does indeed start the docker daemon for you. But I don't need all the fancy features it offers so removed it and was pleased to see about 4GB freed and no extra icon in the system tray.
Now if I need to run docker commands I just begin with:
sudo dockerd &
This way I can have it running on the background on the same shell. Note that in this example I have setup sudo without password. If a password is required, I can do sudo dockerd and open another terminal tab.
Although this works as a quick temporary solution I've seen it cause network issues so I would not recommend it, and prefer using a light VM instead.
I've tried soooo many things, and the stuff that worked for me, and no one ever mentioned to try:
(from Windows Powershell)
wsl --set-default <my-distro>
then and there, I could connect to docker without changing the DOCKER_HOST var.
1.open windows docker desktop --> Setting -->General --> Disable Expose daemon on tcp://localhost:2375 without TLS
2.and then Go to Settings --> Resources --> WSL integration --> uncheck Enable integration with my default WSL distro and turn off integration with distro
3.click apply and restart
4.then go to ubuntu
try docker ps
docker ps
if it does not work, continue to run the following command
unset DOCKER_HOST to disable DOCKER_HOST
Today I just tried it successfully
good luck to you
I have found my issue was due to mis-reading instructions., fixed on my windows version 1909 and WSL 2 with the following commands on CMD:
wsl.exe -l -v
wsl.exe --set-version ${distro-name} ${wsl version}
example:
C:\Users\xxxxx>wsl.exe -l -v
NAME STATE VERSION
* Ubuntu-18.04 Running 1
docker-desktop-data Running 2
docker-desktop Running 2
C:\Users\xxxxx>wsl.exe --set-version Ubuntu-18.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
That's it
ISSUE: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375
Powershell
wsl -l -v # ALL DISPLAY "2"
Linux
unset DOCKER_HOST
/etc/init.d/docker restart
Restart Docker
windows docker restart
windows firewall off
Linux docker processes
docker ps
I had the same problem, the solution for me was to set my Ubuntu as the default wsl distribution: wsl --set-default Ubuntu
For whatever it's worth (this is an old thread). Maybe someone else is still desperately trying to solve this puzzle.
I have just stumbled over the solution in my case.
I am running the following
docker desktop version 3.3.3
wsl 2
Fedora 33
Over and over again I ran into this issue "Cannot connect to the Docker daemon at unix:///var/run/docker.sock". Reinstalled, restarted, blablabla.
My ultimate error were access rights on /var/run/docker.sock, and I am running wsl under my personal user
srw-rw---- 1 root docker 0 May 7 10:29 /var/run/docker.sock
So if I run as root (sudo docker info) or I put myself into group "docker" (sudo usermod -aG docker $USER) I'm all well. Please look here https://docs.docker.com/engine/install/linux-postinstall/
There is another very basic catch:
Ensure virtualization is enabled in the BIOS.
Please enable the Virtual Machine Platform Windows feature from the selection of additional Windows Features.
Now my motherboard is being very old, the BIOS does not support
Enabling Virtualization.
Hence no solution will work for me.
WSL Version 1 or 2 will come from Windows Update automatically.
After hours, my docker worked using following method.
Go to docker desktop --> Setting -->General --> Disable Expose daemon on tcp://localhost:2375 without TLS
Go to Settings --> Resources --> WSL integration --> uncheck Enable integration with my default WSL distro and turn off integration with distro
Restart Docker desktop
Now in WSL,
unset DOCKER_HOST
Now try,
docker ps
The accepted answer is mostly correct. However, I wanted to specify that when using WSL2 + Docker Desktop:
You must unset DOCKER_HOST which was previously needed in WSL1
Mine was defined in ~/.bashrc in both Windows and WSL.
Delete in both. Also delete in Windows env variables via Control Panel.
Check with env | grep -i docker to make sure it's gone.
You must also set the correct settings in Docker Desktop
Uncheck Export daemon on tcp://localhost:2375 without TLS
Check Use the WSL2 based engine
Resources -> WSL Integration -> Check Enable integration with my default WSL distro
Now, you can do a simple docker info to check if you're running the same server version in WSL and in Windows (Powershell).
you can consider upgrading your version to 19582.1000 , it's work for me.
See this issue.
Environment
Windows version and build Version 2004 (OS Build 19037.1)
Docker Edge version 2.1.6.1
Ubuntu 18.04 on WSL 2
Current setup and status:
docker installed on windows
created aliases for docker, docker-compose, docker-credential-desktop, etc ...
Running commands such as docker build, docker ps, docker pull, docker images all work fine. Now I would like push an image and so of course I have to login first.
Problem: logging into docker hub.
I run docker login in the WSL terminal
I put in my username and password
I get the following error
Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in %PATH
%, out: ``
What I've tried so far
docker login from powershell works fine. So I created a symbolic link between /mnt/c/Users/<winusername>/.docker and /home/<wslusername>/.docker. The equivalent works fine for .aws, but for .docker it was not able to share or even acknowledge the credentials, so it asked again for the user and password and threw the same error as above.
This worked for me,
sudo ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe
Linking the executable from windows path to linux path or you can add the windows PATH on you linux PATH.
Refer: https://github.com/docker/for-win/issues/6652
Update Feb 2021
This is all much simpler now. If you are using WSL2 on a recent release of Windows, just install docker on the Windows side and ensure to configurations:
In General: us the WSL 2 based engine
In Resource/WSL Integration: enable integration with your default WSL distro
You will have to restart docker. Once it is done, everything works transparently.
Below here can be ignored
It turns out that the integration between Docker and WSL is better than I thought. Though it could have been better documented. I was going to change tack and try to install docker in the WSL. So I got rid of all the aliases and restarted my session. Lo and behold, when I ran docker there was still something running.
This is because the edge version of docker create the appropriate symbolic links and now I login into docker hub without any problem.
Using the newest version of Docker as of August 25, 2017, I know that Docker no longer requires a VirtualBox setup along with boot2docker to work. However, in trying to connect to it and use docker-compose, I am unable to connect to docker. My compose file works as when I install all necessary prerequisites using homebrew (and therefore use docker-machine), everything is fine. The error message is as follows:
Couldn't connect to Docker daemon. You might need to start Docker for Mac.
I have since done the following to no avail:
remove ~/.docker folder
restart docker through the app
restart the docker app itself
open a new terminal session
It turns out I had some old docker environment variables in my ~/.bash_profile that docker-compose was reading and trying to connect to docker-machine, as a result. After commenting out the following from my ~/.bash_profile:
export DOCKER_CERT_PATH=/Users/williamrwatson/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.59.103:2376
I was good to go:
Creating network "docker_default" with the default driver
Creating docker_redis_1 ...
Creating docker_redis_1 ... done
To begin with, I am behind a corporate proxy. I'm using docker 1.12.0
Using OSX, my .bash_profile looks like this:
export http_proxy='http://server-ip:port/'
export https_proxy='http://server-ip:port/'
export no_proxy='localhost,0.0.0.0,127.0.0.1'
What puzzles me is that I am able to pull the ubuntu image without any problems.
docker pull ubuntu:latest
When I attempt to pull centos I get the following error:
docker pull centos:latest
latest: Pulling from library/centos
8d30e94188e7: Pulling fs layer
dial tcp i/o timeout
I've ready through this post about centos connection issues. I believe I have followed the suggested answers but still no luck.
I am able to pull the image without any problems on my personal machine, so I know it must be something with the proxy. Any suggestions are greatly appreciated!
This is painfully obvious now, and instead of turning to the internet first, I should have simply checked preference options.
In Docker for Mac, v1.12.0 once installed, click on the docker icon in the toolbar (upper right corner next to the clock) and choose "Preferences".
Under the "Advanced" tab, you can enter proxy information.
Thank you BMitch for your time, I appreciate it!
Please pull and save image on your laptop. Transfer the image to the server with no internet connection and use docker load.
Hope this works.
Setting the environment variables in your .bashrc will update the network config for any commands you run as the user. However, Docker is designed as a client/server app, and the image pulls are run from the server (dockerd). Docker has docs on how to configure systemd with a proxy that should solve your issue. In brief, you need to adjust the following:
sudo -s
mkdir /etc/systemd/system/docker.service.d
cat >/etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://server-ip:port/"
EOF
systemctl daemon-reload
systemctl restart docker
exit
If you don't have systemd installed, you should be able to edit /etc/default/docker. The entry you need to add there is export http_proxy="http://server-ip:port/".
Lastly, I'm now seeing that you're on MacOS (the question about CentOS is a red herring since I'm sure you can't pull any image and you're not actually running CentOS). In boot2docker, you have the following procedure:
boot2docker ssh
sudo vi /var/lib/boot2docker/profile
# include your "export HTTP_PROXY=http://server-ip:port/" here
sudo /etc/init.d/docker restart
exit
I installed Docker-Toolbox just now while following their webpage
I started with Docker QuickStart Terminal and see following
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
bash-3.2$
But when I try to perform docker pull hello-world, this is what I see
bash-3.2$ docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository docker.io/library/hello-world
Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/images. You may want to check your internet connection or if you are behind a proxy.
bash-3.2$
What's wrong?
I had the same problem this morning and the following fixed it for me:
$ docker-machine restart default # Restart the environment
$ eval $(docker-machine env default) # Refresh your environment settings
It appears that this is due to the Docker virtual machine getting itself into a strange state. There is an open github issue here
I installed Docker without the Toolbox on Windows 10, so the version that requires Hyper-V to be enabled.
For Docker version 1.12 I had to go into the taskbar, right click the Docker Icon, select Settings -> Network and set the DNS Server to fixed, so that is uses Google's DNS server at 8.8.8.8.
Once that setting was changed, it finally worked.
The simpler solution is to add the following entry in /etc/default/docker file
export http_proxy="http://HOST:PORT/"
and restart the docker service
service docker restart
Update August 2016
Using Docker for Mac (version 1.12.0), was seeing issues of the form:
➜ docker pull node
Using default tag: latest
Pulling repository docker.io/library/node
Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/node/images. You may want to check your internet connection or if you are behind a proxy.`enter code here`
This was resolved by updating my MacBook Pro wireless network settings to include the following DNS entry: 8.8.8.8
For further info, please see this (dated) issue which provided the answer given here.
I ran into this problem running Docker on my MAC(host) with Docker VM in VBOX 5.10. It is a networking issue. The simple fix is to add a bridged network to the VBOX image. You can use the included NAT config present with the VM, but you need to change the ssh port from 50375 to 2375.
sudo service docker stop
sudo service docker start
works for me..
somehow, sudo service docker restart didn't work
(RHEL7)
On Windows 7 and if you believe you are behind proxy
Logon to default machine
$ docker-machine ssh default
Update profile to update proxy settings
docker#default:~$ sudo vi /var/lib/boot2docker/profile
Append from the below as appropriate
# replace with your office's proxy environment
export"HTTP_PROXY=http://PROXY:PORT"
export"HTTPS_PROXY=http://PROXY:PORT"
# you can add more no_proxy with your environment.
export"NO_PROXY=192.168.99.*,*.local,169.254/16,*.example.com,192.168.59.*"
Exit
docker#default:~$ exit
Restart docker machine
docker-machine restart default
Update environment settings
eval $(docker-machine env default)
Above steps are slightly tweaked but as given in troubleshooting guide: https://docs.docker.com/toolbox/faqs/troubleshoot/#/update-varlibboot2dockerprofile-on-the-docker-machine
I ran into this exact same problem yesterday and none of the "popular" answers (like fixing DNS to 8.8.8.8) worked for me. I eventually happened across this link, and that did the trick ... https://github.com/docker/for-win/issues/16
Between Docker for Windows, Windows 10 and Hyper-V, there seems to be a problem during the virtual network adapter creation process. Specifically, you might end up with two "vEthernet (DockerNAT)" network adapters. Check this with Get-NetAdapter "vEthernet (DockerNAT)" (in an elevated PowerShell console). If the result shows more than one adapter, you can disable and rename it with:
$vmNetAdapter = Get-VMNetworkAdapter -ManagementOS -SwitchName DockerNAT
Get-NetAdapter "vEthernet (DockerNAT)" | ? { $_.DeviceID -ne $vmNetAdapter.DeviceID } | Disable-NetAdapter -Confirm:$False -PassThru | Rename-NetAdapter -NewName "OLD"
Then open up Device Manager and delete the disabled adapter (for some reason you can do this from here, but not from the Network and Sharing Center adapters view).
I assume that you have a network problem. Are you behind a proxy? Is it possible that it filters the connection to docker.io or blocks the docker user agent?
I installed the toolbox and ran your test. It works fine, here:
docker is configured to use the default machine with IP 192.168.99.101
For help getting started, check out the docs at https://docs.docker.com
bash-3.2$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
535020c3e8ad: Pull complete
af340544ed62: Already exists
library/hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:d5fbd996e6562438f7ea5389d7da867fe58e04d581810e230df4cc073271ea52
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/userguide/
bash-3.2$
On Windows 10. Just right-click on the systray docker icon-> Settings... -> Rest -> Restrart Docker
I had this same problem with boot2docker and fixed it by restarting it with:
boot2docker restart
I just ran into this today with 1.10.1 and none of the existing solutions worked. I tried to restart, upgrade, regenerate certs, ...
I noticed that I had a lot of networks created on the machine. After removing them with:
docker network ls | grep bridge | awk '{print $1}' | xargs -n1 docker network rm
The DNS started working again.
Note: You may ignore errors about pre-defined networks
If you are behind proxy it is not enough to set HTTP_PROXY and HTTPS_PROXY env. You should set it while machine creation.
Paramer for this is --engine-env:
docker-machine create -d "virtualbox" --engine-env HTTP_PROXY=http://<PROXY>:<PORT> --engine-env HTTPS_PROXY=<PROXY>:<PORT> dev
In my case, installing docker on Alpine Linux I get the error:
Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/........
Using the script here:
https://github.com/docker/docker/blob/master/contrib/download-frozen-image-v2.sh
Works. It downloads the image using curl and then shows you how to untar and 'docker load' it.
I tried the above methods of static DNS at 8.8.8.8 and disabling ipv6 (I didn't understand the proxy thing) and none of them worked for me.
EDIT 9/8/2016:
I was initially using dropbear instead of openssh. Reinstalled Alpine with openssh fixed the problem.
The next problem was 'ApplyLayer exit status 1 stdout: stderr: chmod /bin/mount: permission denied' error during pull.
From (nixaid.com/grsec-in-docker/):
To build the Docker image, I had to disable the following grsec
protections. Modify the /etc/sysctl.d/grsec.conf as follows:
kernel.grsecurity.chroot_deny_chmod = 0
kernel.grsecurity.chroot_deny_mknod = 0
kernel.grsecurity.chroot_caps = 0 # related to a systemd package/CAP_SETFCAP
in alpine's case though it's
/etc/sysctl.d/00-alpine.conf
reboot
Restarting Docker or recreating the image did not help. I rebooted Windows to no avail.
Astoundingly, when I ssh'ed into the running container and did curl https://index.docker.io/v1/repositories/library/hello-world/images I got a perfectly valid response.
I used the Docker Toolbox with VirtualBox on 64bit Windows 10 Pro.
The solution in my case was to uninstall the old Docker version and install the new one that uses Hyper-V instead of VirtualBox.
Now Docker works again.
If you are behind proxy kindly use below commands
sudo mkdir /etc/systemd/system/docker.service.d
sudo cd /etc/systemd/system/docker.service.d
sudo vi http-proxy.conf
[Service]
Environment=HTTP_PROXY=http://proxy-server-ip:port" "NO_PROXY=localhost,127.0.0.1"
sudo systemctl daemon-reload
sudo systemctl show --property=Environment docker
sudo systemctl restart docker
Try this if you can fetch latest ubuntu
sudo docker run -it ubuntu bash
Unable to find image ubuntu:latest locally
latest: Pulling from library/ubuntu b3e1c725a85f: Pull complete
4daad8bdde31: Pull complete
63fe8c0068a8: Pull complete
4a70713c436f: Pull complete
bd842a2105a8: Pull complete
Digest:
sha256:7a64bc9c8843b0a8c8b8a7e4715b7615e4e1b0d8ca3c7e7a76ec8250899c397a
Status: Downloaded newer image for ubuntu:latest
It worked for me finally :)
Another scenario: if your docker network adapter is disabled, it will fail with this error. The adapter is named "vEthernet (DockerNAT)" or similar. Apparently this adapter is involved somehow in the normal docker pull behavior. Enable it back to solve the problem.
Create a systemd drop-in directory for the docker service:
$ sudo mkdir -p /etc/systemd/system/docker.service.d
Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Hope it helps
refer to https://docs.docker.com/network/proxy/
for me, proxy setting without http:// or https:// prefix works.
e.g:
PROXY:PORT
or with / suffix with http:// or https:// prefix
e.:
http://PROXY:PORT/
On Windows this happened when I moved from a work network to a home network.
To solve it, run:
docker-machine stop
docker-machine start
docker-env
"C:\Program Files\Docker Toolbox\docker-machine.exe" env | Invoke-Expression