docker-machine start waiting for IP - docker

I know this is a very often asked question. But none of the solutions I found helped me.
Status:
Windows 7 + VirtualBox + Docker Toolbox
The Docker env worked perfectly for month. Now I didnt use it for a month and now docker-machine start get stuck for waiting for IP. ... Maybe I broke something with Putty or ssh cmd line tool??
It worked perfectly before.
I uninstalled and reinstalled all tools (Vbox, docker, antivirus, firewall...)
tried create with --native-ssh & -d virtualbox
deleted .docker & AppData/.docker folders
tried diffrent memory & ethernet settings on Vbox machines
the machines starts successfully on Vbox
-It just dont works on commandline!
C:\Users\gregor\dev>docker-machine env
Error checking TLS connection: ssh command error:
command : ip addr show
err : exit status 1
output : command-line: line 0: Bad configuration option: ControlMaster
-But it works on Docker quickstart-MinGW
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.102:2376"
export DOCKER_CERT_PATH="C:\Users\gregor\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)
It would be cool to work with it. But I need 'docker' and 'docker-machine' on my command line for different scripts.

Have you tried opening up virtualbox; right click the VM, click Close -> Save VM State. then open up docker quick start terminal. That seem to have worked for me.

Related

Issue with setting up docker on WSL in Windows 10 Home

I am trying to setup docker through WSL(ubuntu) on Windows 10 Home but ran into an issue when trying to use the docker-compose up command:
$ docker-compose up
ERROR: Couldn't connect to Docker daemon at http://localhost:2375 - is it running?
I have the following configuration in my ~/.bashrc file
#Insert new Path for Docker and Alias
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
PATH="$PATH:/mnt/c/Program Files/Docker Toolbox"
alias docker=docker.exe
alias docker-machine=docker-machine.exe
// Other code
export DOCKER_HOST='tcp://localhost:2375'
docker-machine seems to be running fine as the docker ps command shows a list of containers.
From my research, if I were to use Docker for Windows (which does not run on Windows Home) ; I need to turn on the “Expose daemon on tcp://localhost:2375 without TLS” option in the settings. Since I am using “Docker Toolbox + VirtualBox”, I would like to ask what would be the equivalent?
Please let me know if you require further information.
This is a bit tricky because yo need to use two terminals : one in Windows and one in WSL.
What worked for me : I installed docker-machine and virtualbox on Windows. Then I created a virtual machine named default on virtualbox. Then on Windows, with the terminal Git bash for windows, I ran the following commands :
docker-machine start default : it starts the virtual machine. Alternatively, you can start it directly on virtualbox
docker-machine env default: it shows the commands needed to start the linux shell.
Output looks like this
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH="C:\Users\<yourusername>\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $("C:\ProgramData\chocolatey\lib\docker-machine\bin\docker-machine.exe" env default)
Then you switch to WSL. You can access the terminal by typing ubuntu in the research bar
In /.bashrc, you paste the output (replace with your own output)
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH="/mnt/c/Users/<yourusername>/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
Note that I changed the DOCKER_CERT_PATH so that it works on a linux environment
Finally, in WSL, run source /.bashrc
You can then test your install by running docker run hello-world
Remember to keep your virtual machine running.
The following two articles really helped me with the install:
https://www.sitepoint.com/docker-windows-10-home/
https://www.paraesthesia.com/archive/2018/09/20/docker-on-wsl-with-virtualbox-and-docker-machine/

Docker Toolbox setup fails on Windows 8.1

After (successfully, I believe) installing the Docker Toolbox, I get the following error:
$ docker ps
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.26/containers/json: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
Also, when I try to run the docker quickstart terminal, it just prints the following error:
Docker Machine is not installed. Please re-run the Toolbox Installer and try aga
in.
Looks like something went wrong in step 'Looking for vboxmanage.exe'... Press an
y key to continue...
I searched through the docker troubleshooting but didn't find any hint.
I tried installing the toolbox both with and without checking the "Install VirtualBox with NDIS5 driver [default NDIS6]" checkbox.
Try this,
Check if the docker machine exists. Command to check this below.
docker-machine ls
If you still get error then execute step 2 below. If you see any machine listed and it has STATE stopped then execute docker-machine start machine_name eg. docker-machine start default
This step helps you to create a docker-machine.
docker-machine create --driver virtualbox default
I also face some problems like you and I troubleshoot the problem with the following steps in window 8.1.
Install Docker Toolbox
REGENERATE CERTIFICATES
$ docker-machine regenerate-certs default
Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Create new machine default
$ docker-machine create default
Note: It may take a few minutes for downloading boot2docker.iso file.
UPGRADE docker-machine (Optional)
$ docker-machine upgrade
START Docker Quickstart Terminal (or) Run start.sh file under the location => C:\Program Files\Docker Toolbox
RUN HELLOWORLD
$ docker run hello-world
I hope it will help you :-)

Docker commands fails (in Windows) [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
Improve this question
I am trying to use Docker on a windows machine and is hit with every possible issue it seems. My latest one is this:
My machine is running but I can't seem to interact with it using the docker commands. If I run a very standard command like:
docker ps
I get an error message like this:
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v
1.23/containers/json: open //./pipe/docker_engine: The system cannot find the file specified.
So apparently some path is all messed up. Do anyone know which path this is and how to fix this?
Edit (2021) - This answer is for the old Docker Toolbox, not Docker Desktop.
When running docker ps and receiving:
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json: open //./pipe/docker_engine: The system cannot find the file specified.
The following environment properties need to be set:
set DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\machines\default
set DOCKER_HOST=tcp://192.168.99.100:2376
set DOCKER_MACHINE_NAME=default
set DOCKER_TLS_VERIFY=1
This is assuming the %USERPROFILE%\.docker\machine\machines\default is default path where the cert.pem, key.pem, ca-key.pem, and ca.pem docker files are; the virtual machine name's (created by docker-machine create) is default and Virtual Box DHCP Server's lower bound (found under VirtualBox->File->Preferences->Network->Host-only Networks->hover mouse on VirtualBox Host-Only Ethernet Adapter) is 192.168.99.100 and no other VM is running in VirtualBox.
Same issue here on Win 7. Solution:
In the Docker Quickstart window, at the $ prompt run the below line:
your_user#your_machine MINGW64 ~
$ eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)
Then, you'll be able to run "docker run hello-world".
I run into this problem when using docker-machine and I haven't run the docker-machine env command after rebooting. I'm not sure how to do this in cmd.exe, but if you're using powershell try issuing this command:
docker-machine env --shell=powershell | Invoke-Expression
Make sure Hyper-V is up and running:
open elevated command prompt
type bcdedit /set hypervisorlaunchtype auto
reboot
run "Docker for Windows"
I had to deal with the same issue on Windows.
To solve it:
Create a docker machine (only if you have not got one)
docker-machine create default
Get the ENV vars which the docker client needs in order to connect to the docker machine (server) [This you will need to do every time or set in your ENV vars]
docker-machine.exe env default
You can either install them manually or run one of the following depending on your shell environment (cmd, bash, power-shell)
docker-machine env --shell=cmd # you need to run it manually
docker-machine env --shell=bash > env-var-commands-tmp && . env-var-commands-tmp && rm env-var-commands-tmp
docker-machine env --shell=powershell | Invoke-Expression
Open cmd with admin rights.
Execute following command
docker-machine env --shell cmd default
you will receive following output
SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.102:2376
SET DOCKER_CERT_PATH=C:\Users\DBashyal.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
REM Run this command to configure your shell:
REM #FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO #%i
Copy the highlighted line and execute on cmd
#FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO #%i
Execute following command
docker ps
I created a new machine using the below command
docker-machine create --driver=virtualbox vbox-test
Then executed the command
docker-machine env --shell=powershell | Invoke-Expression
Got it Working...
I had a look at all the above answers and none of them worked.
Then I found out that the command has to be run on a linux command line like bash.
so try:
Type the command into the Docker bash terminal VM that comes with the docker toolbox as opposed to the windows cmd
If you have already made sure that your docker has been started
As pointed in other answers you need to set a few environment variables.
The easiest way to do it is:
#FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd') DO #%i
This will run docker-machine env --shell cmd and add those environmental variables.
If you want these variables to be persistent defined them in windows (tutorial).
Right click the Docker icon in the tray a select "Switch to Windows containers...".
You may be prompted to enable the Containers feature. Do so and reboot, again.
To start default host in windows I know three ways given below you can use one of them.
Starting or restarting already created a default machine by the Docker:
docker-machine start default
docker-machine restart default
Now check docker-machine env
The following environment properties need to be set:
set DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\machines\default
set DOCKER_HOST=tcp://192.168.99.100:2376
set DOCKER_MACHINE_NAME=default
set DOCKER_TLS_VERIFY=1
To create a new machine using the following command:
Windows 10/HyperV:
docker-machine create --driver hyperv default
docker-machine create -d hyperv default
Mac, Linux, windows 7 & 8:
docker-machine create --driver virtualbox default
docker-machine create -d virtualbox default
I had similar issue when I installed Docker CE for Windows Version 17.11.0-ce-rc4-win39 (14244) Channel: edge e557194 on Windows 10.
In Command/cmd windows, when I tried to run commands docker ps, docker version, docker info, the I got error like “error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.34/version” every time.
To resolved this issue,
I made “Hyper-V” off (Unchecked) from “Turn Windows feature on or off”, which required the OS to be restarted.
And after first restart, I made “Hyper-V” On (Checked), which again required the OS to be restarted.
After second restart, above docker commands started working and giving proper output.
So, turning Hyper-V off and then on resolved this issue for me.
I got the solution from this issue. It not just like Nikesh's answer said SwitchDaemon could fix it directly. I think you should run this command twice to switch your daemon to your previous daemon.
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
# then check the docker OS/Arch
docker version
# You may see the different OS/Arch
./DockerCli.exe -SwitchDaemon
# then you got your images and containers back
This command is just switch your daemon from your defualt daemon to another daemon(depends on what you set). When you switch to another daemon, the images and containers on the former daemon will disappear(but not deleted).
I have had this issue on a Windows 2016 machine. Happened because the docker service wasn't started. In my case the docker service as failing with the following error
fatal: Error starting daemon: pid file found, ensure docker is not running or delete C:\ProgramData\docker.pid
Deleting the C:\ProgramData\docker.pid file did the trick.
below resolved. i copied answer from another forum
I had this problem after update. After re-installing VB I switched on "VirtualBox NDIS6 Bridged Networking Driver" in properties network connection.
It property switched off default in my case.
Windows 10 Professional
For me the Docker service was running but Docker still needed to be 'started'. That is, I had the setting 'Start Docker when you log in' unchecked in the Docker tray icon.
Prior to finding this out I had gone to the program folder Docker and clicked 'Docker for Windows'. After a short time the message 'Docker is running' was displayed.
For me, this error was resolved after I removed daemon.json file in "%programdata%\docker\config"
The content in my daemon.json is the following:
{
"hosts": ["tcp://0.0.0.0:2375"]
}
I created this manually as part of some testing. But after I restarted the server, I started to get the error in this question.
The error is really troubling. I hope Docker Developers do something about. It took a lot of try and error to get around. Thanks to Stackoverflow and other blogs. In my case, I am using Windows 10 Pro. I settled with DockerToolbox.exe after several failed attempts with Docker for Windows Installer.exe. Then I encountered An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v . The followed these steps and the problem got solved.
First, I went to Control Panel -> Turn Windows Features On or Off and unchecked Hyper-V
Next, Open PowerShell as Admin:
docker-machine env --shell=powershell | Invoke-Expression
type bcdedit /set hypervisorlaunchtype auto
Restarted my System. Then I launched "Docker Quickstart Terminal", then I entered this on the shell window.
run "Docker for Windows"
docker run hello-world
I it went well. Then I open Command Prompt
docker run hello-world
It gave the error: Then I entered
set DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\machines\default
set DOCKER_HOST=tcp://192.168.99.100:2376
set DOCKER_MACHINE_NAME=default
set DOCKER_TLS_VERIFY=1
Most of the suggestions above too are helpful.
I saw this error message after a weekend. My setup was fine before that. My config and connections looked correct. $docker-machine restart default fixed it for me on Windows 7
I was getting this error, while running the command docker-compose up. The problem for me was, the docker service was not running. So I had to run services.msc and start the docker service.
I solved this error by run the {DOCKER_TOOLBOX_INSTALL_PATH}start.sh in bash.
In my case, all above solutions did not resolve. Instead zilurrane response helped.
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
Switch to Windows Containers
docker info
docker ps
Switch back to Linux containers
docker info
Viola!
The windows switch likely runs the missing configurations that Linux also needs.
I was having similar issue. For me I hadn't logged in to docker from the status bar. What I did was to login to docker from status bar. Once I logged in I was able to run all the commands properly.
Try logging in using your docker id and password maybe that will resolve your issue.
I had the same issue on my Windows 10. Find below what I did to solve it:
After installing Docker, Just restart your PC, run docker application (It may require enabling Hyper-V), then open command line and type:
docker run hello-world
Everything works fine :)
I had this problem. I searched a lot. I checked many things. But in the end, the solution that solved my problem was the following solution.
System Environment:
Windows 10 Professional
Windows engine in Docker
Docker version 20.10.21
Solution
disabled IP6
And
Restarted the service and application

Error checking TLS connection: Error checking and/or regenerating the certs

After I restarted my windows i cannot connect to docker machine running in Oracle Virtual Box.
When i start Docker QuickStart Terminal every thing looks fine, it's coming up OK and it gives me this message:
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
but when i do:
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Timeout
and:
λ docker images
An error occurred trying to connect: Get http://localhost:2375/v1.21/images/json: dial tcp 127.0.0.1:2375: ConnectEx tcp: No connection could be made because the target machine actively refused it.
also when i try to reinitialize my env., i get:
λ docker-machine env default
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": dial tcp 192.168.99.100:2376: i/o timeout
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which will stop running containers.
BTW, Regenerating certs also not helping.
Any idea?
Thanks.
Please try regenerating certificates manually by:
docker-machine --debug regenerate-certs -f default
and check for any errors to fix, then try again:
docker-machine --debug env default
If it's failing on ssh, copy and paste that command into terminal to see what's the problem by adding extra -vv.
If you've got:
debug1: connect to address 127.0.0.1 port 64368: Connection refused
then your machine isn't running (check by docker-machine ls), so try:
docker-machine start
Then try to ssh to it via:
docker-machine -D ssh default
After doing some research I found out that following workaround may solve the issue for now:
Open Network And Sharing Center
Click on Change Adapter Setting
See if you have any enabled adapters such as VPN or VM Ware network adapters.
Try to disable them and try to connect to your container one more time
If it didn't work while you have other adapters disabled, Restart your PC - in my case this worked for me.
What worked for me is this answer from the docker-machine repo:
docker-machine regenerate-certs --client-certs [name]
Basically, what expired is client certificates. The error message I get from docker-machine is similar to yours (i.e., no indication it's the client certs that need to be regenerated).
I fix it doing this:
Removed all host-only interfaces from my VirtualBox (VirtualBox → Preferences → Network → Host-only networks).
rmdir.exe --ignore-fail-on-non-empty ~/.docker/
docker-machine start
docker-machine env
eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default) (added also at the end of my .bash_profile).
docker run hello-world ← now working
Inspired in this post.
Here is what worked for me. The first steps are similar to what Hazhir proposed, then followed by regenerate the certificates.
Open Network And Sharing Center.
Click on Change Adapter Setting.
Disable all active VMWare network adapters. Usually has explanation "VirtualBox Host-Only Ethernet Adapter".
Connect to your container by running docker-machine start.
Run docker-machine env. If you're like me then you'd get following error:
Error checking TLS connection: Error checking and/or regenerating the
certs: There was an error validating certificates for host
"192.168.99.100:2376": x509: certificate is valid for 192.168.99.101,
not 192.168.99.100
Which is good. Now all we need to do is to run
docker-machine regenerate-certs -f default
Then test it again with docker-machine env. If you get:
SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.100:2376
SET DOCKER_CERT_PATH=C:\Users\Jay\.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
REM Run this command to configure your shell:
REM FOR /f "tokens=*" %i IN ('docker-machine env') DO %i
Then you're all set. In my case I needed to start my virtual machine by running Docker Quickstart Terminal.
I have this problem too. Execute docker-machine regenerate-certs <vm-name> can not solve problem. I search Google the error info and find the solution below.
execute sudo ifconfig vboxnet0 up in terminal.
show docker machine state: docker-machine ls.
now STATE and URL are ok.
But restart the system this problem persists.
GitHub issues link I found is here.
It seems there is a bug in VirtualBox 5.1.24.
Just start the docker machine and then regenerate certificates
docker-machine start <machine-name>
docker-machine regenerate-certs <machine-name>
It works like a charm for me.
None of the answers here helped me. My problem occurred when I want to activate the shell of my virtual machine with eval $(docker-machine env default).
It was then trying to access the port 2376 which was closed, so I had to enter the shell of the VM through ssh and activate the following UFW rule:
sudo ufw allow 2376
The way I ensure being able to connect to my docker machines is by assigning them a fixed IP (and regenerating the certs only once) (no reboot needed)
After that, docker-machine ls always work.
My current script:
(replace %PRGS%\dm\latest by the path where docker-machine.exe is on your machine)
(make sure PATH include the latest /path/to/git/usr/bin, for commands like ssh to be available)
> more dmvbf.bat
#echo off
setlocal enabledelayedexpansion
set machine=%1
if "%machine%" == "" (
echo dmvbf expects a machine name
exit /b 1
)
set ipx=%2
if "%ipx%" == "" (
echo dmvbf x missing ^(for 192.168.x.y^)
exit /b 2
)
set ipy=%3
if "%ipy%" == "" (
echo dmvbf y missing ^(for 192.168.x.y^)
exit /b 3
)
%PRGS%\dm\latest\docker-machine.exe ssh %machine% "sudo sh -c 'echo \"kill \$(more /var/run/udhcpc.eth1.pid)\" | sudo tee /var/lib/boot2docker/bootsync.sh >/dev/null'"
%PRGS%\dm\latest\docker-machine ssh %machine% "sudo sh -c 'echo \"ifconfig eth1 192.168.%ipx%.%ipy% netmask 255.255.255.0 broadcast 192.168.%ipx%.255 up\" | sudo tee -a /var/lib/boot2docker/bootsync.sh >/dev/null'"
%PRGS%\dm\latest\docker-machine ssh %machine% "sudo chmod 755 /var/lib/boot2docker/bootsync.sh"
%PRGS%\dm\latest\docker-machine ssh %machine% "sudo cat /var/run/udhcpc.eth1.pid | xargs sudo kill"
%PRGS%\dm\latest\docker-machine ssh %machine% "sudo ifconfig eth1 192.168.%ipx%.%ipy% netmask 255.255.255.0 broadcast 192.168.%ipx%.255 up"
For instance:
dmvbf default 99 100
docker-machine regenerate-certs -f default
That will assign 192.168.99.100 to the docker machine 'default', and regenerate the certs once.
Then each time docker-machine ls is called, it will display the same IP for 'default'.
Try this way/workaround:
firstly make sure there are ca.pem, cert.pem, key.pem, ca-key.pem under $yourhome/.docker/machine/certs/ folder , for these lost four *.pem files, you can copy them from other places or maybe create them yourselves ( these four pem files are surely not correct at the beginning )
make sure the env set correctly in bash_profile, like:
export DOCKER_HOST=tcp://192.168.99.100:2376
export DOCKER_MACHINE_NAME=default
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH=/Users/johnwang/.docker/machine/machines/default
rerun the cmd: docker-machine regenerate-certs default (maybe before run this, you need reopen the docker terminal)
Tried on docker toolbox on mac, and it works.
Finally some logs of the result:
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": x509: certificate signed by unknown authority
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.
...
...
johns-MacBook-Pro:certs johnwang$ docker-machine regenerate-certs default
Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
johns-MacBook-Pro:certs johnwang$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Running tcp://192.168.99.100:2376 v17.03.1-ce
Hope it helps
also see my response here:https://github.com/docker/machine/issues/2808
In my case it was my FortiClient that caused the issue. After disabling it docker-machine env default worked fine again. I suggest you to check if there's any anti-virus program running in your system.
for me, running
docker-machine --debug regenerate-certs -f name_of_your_vm
worked just fine.
docker-machine version 0.16.1
virtualBox 6.0
also docker was configured to use the default machine with IP 192.168.99.100
I had the same error. I fixed it by open tcp port 2376 in network firewall.
The solution for my problem is taken from here:
https://github.com/docker/machine/issues/3845#issuecomment-271935924
Quote:
If you install docker-machine first time then you do not have in that
host a self-signed CA that will be used to generate your client
certificate and as many server certificates as machines you generate
later on. That CA is generated when you try to create a machine if
that CA is not yet created. So if you try to generate several servers
in parallel (by means of an script), then you’ll generate as many
self-signed (root) CA as docker createcommands, all of them being
written in the same location that seems to be messing up the
environment e.g. spreading out different ca.pem to the remote machines
that do match the final version, causing the cert.pem (host identity)
to be signed by a former ca.pem which no longer exist… or whatever
other abnormal situation.
To fix it, first of all you'll need to delete your existing
self-signed CA. This can be done by removing the folder
~/.docker/machine/certs (NOTE: Note this will force the creation of a
new self-signed CA for docker-machine to use and will yield your
existing machines to fail connecting to the daemon). This will make
your docker-machine to generate valid certificates again. Then, for my
use case I am creating the first machine in foreground and all the
rest of them are done in parallel. That will cause the creation of one
root self-signed CA in isolation and then will be used for further
docker-machine create commands. It worked like a charm!
The reason why I was able to ssh to the host is because there are a
different pair of keys for sshing generate per host that was not
bitten by this.
To sum up, this is what I ended up doing:
Find out what is the command that docker-machine is running. I was using it with gitlab-runner, So I had to run gitlab-runner in debug mode to see what command was it running on docker-machine.
then stop gitlab-runner: gitlab-runner stop
then delete the certificate: rm -rf ~/.docker/machine/certs
then run a single command (from step #1) to re-create the certs (remember - the reason this didn't work is because it was trying to create it multiple times)
then rerun gitlab-runner: gitlab-runner start
Worked for me!
For reader using brew in 2021, after your somehow upgrade virtualbox cask
System Preferences... > Security & Privacy > (Unlock with finger) Allow.
<<Your Computer Should Restart>>.
docker-machine restart default. Done
Solved this issue in MacOS by installing Docker Desktop
brew uninstall docker
brew uninstall docker-machine
Then download Docker Desktop for mac https://docs.docker.com/desktop/mac/install/

Network timed out while trying to connect to https://index.docker.io

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

Resources