05 August 2014

Not too long ago, the Docker project released 1.0 release, which among many improvements includes a new default port for Docker. To update from Docker < 1.0 to Docker >= 1.0, you may run into issues as the port that Docker listens on by default has changed from 4243 to 2375. While things may appear to start correctly after an upgrade, you may see the following error when attempting to run any Docker client command:

$ boot2docker up

Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

This is because your Virtual Box "boot2docker-vm" image is still listening on the old port and therefore is not receiving the forwarded commands. You can verify this by starting up Boot2Docker and ssh’ing (boot2docker ssh) into the VM to check the port that docker is listening on:

docker@boot2docker:~$ sudo netstat -ntpl | grep docker
tcp        0      0 :::4243                :::*                    LISTEN      627/docker

To fix this, use the following steps:

  1. Update to latest Boot2Docker and Docker via Homebrew (installing Boot2Docker will automatically install/update Docker to the corresponding version).

  2. Run boot2docker delete.

  3. Delete the existing ~/.boot2docker directory.

  4. Run boot2docker init

  5. Open Virtual Box, select the boot2docker-vm and click on the "Settings" button.

    1. Click on the "Network button" in the settings window, expand the "Advanced" area and click on the "Port Forwarding" button. Verify that 2375 and 2022 are in the list.

  6. Run boot2docker up

  7. Run boot2docker ssh

  8. In the VM, run the following command to verify that Docker is listening on port 2375:

sudo netstat -ntpl | grep docker

docker@boot2docker:~$ sudo netstat -ntpl | grep docker
tcp        0      0 :::2375                 :::*                    LISTEN      627/docker

You should now be able to connect to Docker and use the command line client and the REST API!

comments powered by Disqus