7

I'm setting up Docker on my local Mac OS X machine and am running into some issues getting it to work. I have followed the installation instructions at https://docs.docker.com/installation/mac/. Everything up to installing the boot2docker tool appears to go smoothly, but after the VM is running, Docker commands seems to do nothing. E.g.,

$ docker run ubuntu echo hello world
2014/06/17 08:20:54 Post http://localhost:4243/v1.12/containers/create: EOF

Every command ends in EOF and doesn't seem to do what it actually should do. Here's another:

$ docker ps
2014/06/17 08:25:10 Get http://localhost:4243/v1.12/containers/json: EOF

The VM created by the boot2docker tool is running as well:

$ boot2docker status
[2014-06-17 08:26:24] boot2docker-vm is running.

I have a feeling something is not set up correctly, but I followed the instructions line by line and can't see where something is going wrong.

Any help is much appreciated, thanks!

Update 1

boot2docker version: 1.0.0 or 0.9.1 (not sure--there's no version flag AFAICT)

$ boot2docker ip
Usage /usr/local/bin/boot2docker {init|start|up|save|pause|stop|restart|status|info|delete|ssh|download}

On the boot2docker instance:

$ sudo netstat -ntpl | grep docker
tcp        0      0 :::2375                 :::*                    LISTEN      743/docker

$ docker --version
Docker version 1.0.0, build 63fe64c

Update 2

I just re-installed boot2docker and now I am definitely running 1.0.0.

$ boot2docker version
Client version: v1.0.0
Git commit: 2fef7b2

I also re-ran the command in the documentation (which conflicts with what the command told me to set the DOCKER_HOST on the command line, see below):

$ boot2docker up
2014/06/17 18:25:43 Waiting for VM to be started...
.............................
2014/06/17 18:26:41 Started.
2014/06/17 18:26:41 Auto detection of the VM's IP address.
2014/06/17 18:26:41 To connect the Docker client to the Docker daemon, please set:
2014/06/17 18:26:41     export DOCKER_HOST=tcp://:4243

But I am still seeing the original issue.

$ docker run ubuntu echo hello world
2014/06/17 18:28:29 Post http://127.0.0.1:4243/v1.12/containers/create: EOF

I then re-run the command mentioned in the documentation:

$ export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375

And now see this:

$ docker run ubuntu echo hello world
2014/06/17 18:31:39 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

I should mention that trying to run docker -d on OS X shoots out this message:

$ docker -d
2014/06/17 18:34:04 The Docker daemon is only supported on linux

Which is not much help...

5
  • 1
    Can you provide a little more debugging information? boot2docker version at least? Maybe also SSH to the boot2docker VM and get docker -version output? I suspect this is a VM port forwarding issue with the latest boot2docker which upgraded to Docker 1.0, which uses a new port.
    – Andy Shinn
    Jun 17, 2014 at 20:29
  • 1
    It also appears your client port is wrong (at least for Docker 1.0). I created an answer with two possible issues that may be happening.
    – Andy Shinn
    Jun 17, 2014 at 20:38
  • 2
    Why is this off topic? Seems like a perfectly valid question to me. I ran into similar issues.
    – Andy Shinn
    Jun 18, 2014 at 21:27
  • @AndyShinn apparently, asking a question about a "development environment" is grounds for closure. Guess one has to wonder where one can ask questions such as these without getting closed... Jun 19, 2014 at 1:14
  • 2
    I didn't realize it. But I guess when they say "professional" they mean more "production system" problems. Since you ask about running containers on a Mac they must assume this is a development environment. The question might have been better for Stack Overflow. I was always under the impression that Server Fault was for server and daemon related questions where Stack Overflow was more code based. But I guess my assumptions were a little off.
    – Andy Shinn
    Jun 19, 2014 at 1:38

2 Answers 2

12

A couple things to check:

Updated version of boot2docker

Check that your boot2docker is up to date. If you had installed through an application such as Homebrew, you might be running an older version. Check the official releases at https://github.com/boot2docker/osx-installer/releases. Be sure to run boot2docker delete and then boot2docker init after upgrading.

Updated Docker client

It is probably a good idea to run a Docker client that matches the version of server running in boot2docker. If you are running Docker 1.0 in boot2docker, make sure you have the 1.0 client from https://github.com/boot2docker/osx-installer/releases.

Export correct port

The port in your commands may not be correct. Did you remember to run export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 like the documentation says? Port 2375 is the new default for Docker 1.0 (which is in both boot2docker 0.9.1 and 1.0.0).

Forward correct port

After updating the DOCKER_HOST for the client, you may run into an issue with boot2docker 0.9.1 which used the wrong port for Docker TCP connections. Steps to check:

  1. Login to the boot2docker VM using boot2docker ssh (password is tcuser).
  2. Then check the listening port using sudo netstat -ntpl | grep docker (probably 2375).
  3. Now open up VirtualBox, go to the settings of the boot2docker VM, then click the Port Forwarding button.
  4. It should match the port listening in boot2docker (possibly 2375).
  5. If the port doesn't match, try updating the port forwarding, then try the client again.
2
  • Hey Andy, thanks for your answer. I've updated the question with some followup information. I think I'm running 0.9.1, but I'm not quite sure, since after sshing into the VM it says "boot2docker: 1.0.0". I'll reinstall in a moment. Jun 17, 2014 at 23:12
  • Also--"boot2docker ip" seems to fail. Maybe I am running the wrong version... Jun 17, 2014 at 23:14
5

Andy got me 99% of the way there. I'm marking his answer as the accepted answer, but I'll write here what solved my issue. After installing the correct version (1.0.0) of boot2docker, I was still getting incorrect output from any Docker commands.

I then opened up VirtualBox and read the ports, and, lo and behold, the ports were incorrect. However, switching them to the correct values did not fix the problem.

I decided to reset the VM, since the old boot2docker probably set it up incorrectly. The following commands ended up fixing the issue.

$ boot2docker delete
$ boot2docker init
$ export DOCKER_HOST=tcp://:2375
3
  • Ah, I guess I assumed you were sticking with a version. Upgrading a version would definitely mean re-initializing the VM.
    – Andy Shinn
    Jun 18, 2014 at 21:42
  • 1
    I went ahead and updated my answer to be much more thorough.
    – Andy Shinn
    Jun 19, 2014 at 0:22
  • Starting in version 1.2.0 of boot2docker there's a new cli verb, shellinit included so you can do this instead to set the env. var. $DOCKER_HOST. eval $(boot2docker shellinit).
    – slm
    Sep 3, 2014 at 19:05

Not the answer you're looking for? Browse other questions tagged .