I'm having a recurring problem with Docker Machine - every few days it decides to timeout and I am unable to recover it once this happens.
Example
docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default virtualbox Timeout
Environment Info
uname -a Darwin ColeyMBPR 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64
docker version 1.11.0
docker-machine version 0.7.0
vboxmanage --version 5.0.20r106931
Attempted Solutions
I've tried the following things in no particular order:
Restarting the docker machine.
Running eval "$(docker-machine env default)"
Regenerating the certificates docker-machine regenerate-certs default
Restarting my host box.
Upgrading Docker.
Reinstalling Docker.
Upgrading VirtualBox.
Removing all VirtualBox host-only network devices.
Hack
The only thing that's working for me right now is destroying the docker machine and recreating it. This destroys all my images and containers, and it's incredibly time consuming to set it up again.
docker-machine rm -y default && docker-machine create -d virtualbox default && eval $(docker-machine env)
Is there anything I can try? Thanks!
Update: 9th May (Steps to Reproduce)
I can reliably reproduce this problem with the following steps:
Start with a freshly created Docker machine.
Use docker-compose up to build some containers.
Shutdown the computer with the containers running.
After reboot the Docker CLI doesn't work due to the Docker machine timing out.
This command worked for me with the digitalocean driver:
docker-machine ls -t 20
It seems as though the default timeout of 10 seconds was too short.
This is usually a problem related to the way you start and stop your machine.
You can solve it using
$ docker-machine stop default
$ docker-machine start default
$ docker-machine regenerate-certs default
Do not use docker-machine restart default because it will not refresh your networking configs.
Check if you are are using a proxy or VPN!
None of the above suggestions worked for me until I turned off my VPN and suddenly:
docker-machine.exe ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.102:2376 v19.03.5
I had the same issue with Docker version 1.11.2, build b9f10c9
This worked for me - my docker machine is back to the Running state
$ docker-machine restart
$ eval $(docker-machine env)
So far I have a bit of a hacky solution - this fixes the docker machine but destroys all containers and images.
Script: rebuild-machine.sh
docker-machine rm -y default
docker-machine create -d virtualbox default
docker-machine stop default
VBoxManage modifyvm "default" --natpf1 "Forwarding App 1,tcp,127.0.0.1,3000,,3000"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 2,tcp,127.0.0.1,3001,,3001"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 3,tcp,127.0.0.1,3004,,3004"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 4,tcp,127.0.0.1,3005,,3005"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 5,tcp,127.0.0.1,3006,,3006"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 6,tcp,127.0.0.1,8081,,8081"
docker-machine start default
eval $(docker-machine env)
Explanation
Destroys the default docker machine, containers and images.
Creates a new docker machine on VirtualBox and stops it so we can modify VirtualBox.
Adds port forwarding for various applications on VirtualBox.
Starts the docker machine.
Ensures the Terminal is setup for the new IP address of the docker machine.
My problem was very simple. I was blocking port 2376 with my ufw firewall. Docker-machine needs this port open to connect to the remote.
I found the answer to my problem in on this page:
I have opened virtualbox and closed and start all vm manually/. State is running again
This worked for me and my containers were not destroyed:
Opened Oracle virtual box and paused the VM
Restarted the VM on docker machine
$ docker-machine restart default
docker version: 1.12.3
docker-machine version: 0.8.2, build e18a919
My problem was very trivial - I did the docker machine ls command right after restarting a docker machine, so it was not running yet, and that caused a timeout.
Related
I'm trying to start the default machine of Docker on Mac OSX.
Everytime i'm trying to start a new default machine by command:
docker-machine create --driver virtualbox default
of using Docker Quick Start Terminal It stucks on
(default) Creating SSH key...
This is the output:
Running pre-create checks...
Creating machine...
(default) Copying /Users/avivpaz/.docker/machine/cache/boot2docker.iso to /Users/avivpaz/.docker/machine/machines/default/boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
This is my OSX and Docker versions:
Mac 10.11.3
docker-machine version 0.6.0, build e27fb87
That seems to be followed by issue 2788 and more related to VirtualBox than docker machine.
Try and reboot the Mac, or make sure there is no VBox... process.
First, just delete the boot2docker.iso from ~/cache directory and once again restart the docker terminal. If will download the fresh latest boot2docker.iso and you are good to go.
If it's not working manually download the latest boot2docker.iso and place it into the above directory of cache
/Users/{user}/.docker/machine/cache/
$ ~/.docker/machine/cache
$ ls
boot2docker.iso
And, finally run to create an virtual machine,
docker-machine create --driver virtualbox default
And, again, you are good to go. Hope this helps.
I've installed Docker on my Mac about a month ago, and I now wanted to use it again. The command eval "$(docker-machine env default)" used to work perfectly before, but I now get an error:
Error checking TLS connection: default is not running. Please start it
in order to use the connection settings
I searched around for this error, but I can't really find anything about it. Does anybody know what I should do to solve this? All tips are welcome!
Your boot2docker virtual machine must be running inside Virtualbox.
List your Docker machines:
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Stopped Unknown
Start default machine:
$ docker-machine start default
Starting "default"...
(default) Check network to re-create if needed...
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
To recreate your default machine:
$ docker-machine rm default
$ docker-machine create --driver virtualbox default
Then you should be able to setup your env with eval "$(docker-machine env default)".
So im having some weird problems with docker-machine. I am trying to set up a docker-machine on my Mac OS El Capitan and also have the daemon flagged for a few insecure registries. I was able to successfully push/pull on a local Ubuntu install (without docker-machine) by setting the DOCKER_OPTS options to flag my insecure Nexus docker registries. I am trying to accomplish the same end goal on my Mac OS. So far I have installed the Docker Toolbox using a default installation and have tried the following in Terminal.
Vinays-MacBook-Pro:~ Vinay$ sudo docker-machine create --driver virtualbox --
engine-insecure-registry mynexusrepo.cloudapp.net:18443 --engine-insecure-registry mynexusrepo.cloudapp.net:18444 --engine-insecure-registry mynexusrepo.cloudapp.net:18445 dev
Creating VirtualBox VM...
Creating SSH key...
Starting VirtualBox VM...
Starting VM...
To see how to connect Docker to this machine, run: docker-machine env dev
Vinays-MacBook-Pro:~ Vinay$ eval "$(sudo docker-machine env dev)"
Vinays-MacBook-Pro:~ Vinay$ sudo docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
dev virtualbox Running tcp://192.168.99.100:2376
Vinays-MacBook-Pro:~ Vinay$ sudo docker pull mynexusrepo.cloudapp.net:18445/docker-thirdparty/mongodb:3.0.2
Password:
Post http:///var/run/docker.sock/v1.20/images/create?fromImage=mynexusrepo.cloudapp.net%3A18445%2Fdocker-thirdparty%2Fmongodb%3A3.0.2: dial unix /var/run/docker.sock: no such file or directory.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?
Vinays-MacBook-Pro:~ Vinay$ sudo docker images
Password:
Get http:///var/run/docker.sock/v1.20/images/json: dial unix /var/run/docker.sock: no such file or directory.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?
Vinays-MacBook-Pro:~ Vinay$ docker-machine -version
docker-machine version 0.4.1 (e2c88d6)
So I know the sudo docker pull mynexusrepo.cloudapp.net:18445/docker-thirdparty/mongodb:3.0.2 command works since it works fine on my straight Ubuntu OS with a docker install. Is there something else I am missing? I have tried closing all the terminals, deleting all of the docker-machines, restarting, etc.
Thanks!
I'm new to Docker...
From my understanding, Docker is only compatible with Linux, is it possible to run docker for development purposes on a Mac?
I installed virtualbox using homebrew and have tried to create a virtualbox instance. I installed docker, but am having trouble getting my mac to communicate with the vm docker instance. My end goal is to get a locally debuggable instance of tomcat running on the docker container.
Any help or tips would be helpful.
Information:
Because Docker only runs on Linux you will need to install some kind of virtual instance on your local machine. An easy and popular way to do that is to install
Boot2docker and VirtualBox. VirtualBox is a dependency of Boot2docker. You can download, setup and install the latest versions from their websites or if you are using Homebrew, as you mentioned, you can quickly get the working binaries both in one step.
After installing boot2docker, you're ready to use Boot2docker to create a Tomcat Container. You can find a pre-configured tomcat image by searching Docker's community repository, docker hub registry.
Notes:
Each time you execute the docker run command a new container is created.
The VM running Docker requires a ssh private/public encryption key handshake to connect to. If you follow my steps below, one will be generated for you.
Steps to Setup Tomcat using the tomcat image:
Open Terminal and run this command: brew install boot2docker
Create a new Boot2Docker VM instance using the init command: boot2docker init
Run this command in Terminal to forward local ports to the vm:
for i in {10000..10999}; do VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i”; VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";done
Start the boot2docker daemon: boot2docker start or boot2docker up
After starting docker, copy the exports that are displayed from the previous command to your clipboard
Edit your bash profile file ~/.bash_profile (or if you are using zsh, edit the resource configuration file ~/.zshrc) with a text editor (I prefer using Sublime text): subl .zshrc *note: this will permanently save the docker env variables.
Paste the exports into that file and save
Execute the source command on the file: source .zshrc
Pull the latest tomcat image to create a container and start tomcat: docker run -it --rm -p 10080:8080 tomcat:8.0 *note: this will forward your local 10080 port to the vm's 8080 port.
Go to http://localhost:10080, you should see the tomcat start page!
Useful Docker commands:
$ boot2docker status
$ docker version
$ docker ps #shows running containers
$ docker ps -a # shows all containers
$ docker exec -it NAME /bin/bash #to start a bash session on the container. -i = interactive, -t = tty
External Resources:
https://docs.docker.com/installation/mac/#installation
https://registry.hub.docker.com/_/tomcat/
Most people use boot2docker to run on Macs. You may also want to take a look at Kitematic, which gives you a GUI to play with.
Finally, the future is probably to use docker machine, which can provision a VM for you.
Docker requires Linux Kernel features, hence it cannot be run natively on OSX.
See instead Boot2Docker. This link gives you instructions on how to get going.
I've installed boot2docker (full install) on Windows 7 and am trying to run the container port redirection demo:
docker run --rm -i -t -p 80:80 nginx
Which looks like it isn't quite finishing properly, it just stops and looks like this:
When I open another git bash shell and run boot2docker ip I get 192.168.59.103, and when I pop that in chrome I get Error code: ERR_CONNECTION_TIMED_OUT
It works fine for me with plain docker on Ubuntu 14.04. What else do I need to do to make it work with boot2docker on windows?
Looking more closely, my problem is the same as this question: Docker, can't reach “rails server” development from localhost:3000 using docker flag -p 3000:3000
The answer to that question that worked for me was this one, which simply says to run
boot2docker ssh -L 8080:localhost:80
at the terminal before starting boot2docker
In my case I do this (from a git bash terminal):
boot2docker init # from https://github.com/boot2docker/boot2docker
boot2docker up
boot2docker ssh -L 8787:localhost:8787 # sets up port forwarding and starts boot2docker
docker run -d -p 8787:8787 cboettig/rstudio # starts the container I want
then go to my web browser in windows and point it to http://localhost:8787/ and I get a server instance of RStudio. When I'm done:
docker rm -f $(docker ps -a -q) # delete all containers
UPDATE: downgrading to an earlier version of VirtualBox will fix this
After struggling with folder sharing I regressed through previous versions of VirtualBox and found that with version 4.3.12 I could enable folder sharing and have the port forwarded exactly according to the official instructions, that is I could access my docker container at 192.168.59.103. So downgrading VirtualBox is another option for working around this problem.
ANOTHER UPDATE: updating to the new release of v1.3.1 of boot2docker will fix this
This release just came out a week ago and includes VirtualBox Guest Additions, which simplifies all of this. I now simply do
boot2docker ssh # start boot2docker
docker run -d -p 8787:8787 -v /c/Users/foobar:/home/rstudio/foobar rocker/rstudio
And I get everthing working as expected and can log into RStudio in my browser at http://localhost:8787/ (linux) or http://192.168.59.103:8787 (Windows) and it just works.
In this case I've also got folder sharing working with, /c/Users/foobar corresponding to an existing folder on my computer at C:/Users/foobar, and foobar can be anything. With this method I can read and write files both ways between Windows and RStudio and I don't need to connect to a special IP address like the samba method does in the official docs
I had this problem too after a couple of failed attempts to boot2docker start. This created multiple entries of host-only networks configured on VirtualBox (VirtualBox Host-Only Ethernet Adapter #2, VirtualBox Host-Only Ethernet Adapter #3), and probably the boot2docker's VM was using a bad one.
I cleaned up using Virtualbox standard UI, leaving only one of the networks and now everything works fine.
I'm using boot2docker 1.5.0.
Just to register something that happened to me, and made me lose a couple of hours.