Skip to content

Instantly share code, notes, and snippets.

@baseboxorg
Forked from mboersma/DockerMacClient.md
Last active August 29, 2015 14:07
Show Gist options
  • Save baseboxorg/3c156299ccbdc5ef13e1 to your computer and use it in GitHub Desktop.
Save baseboxorg/3c156299ccbdc5ef13e1 to your computer and use it in GitHub Desktop.

Run Docker client on Mac OS X connected to a Linux VM

Official Mac Docker Binary!

None of this is really necessary now that the Docker team is releasing official Mac OS X binary builds. Please see moby/moby#3337 for details.

You may also wish to check out this convenience wrapper for setting up essentially what I describe below: https://github.com/noplay/docker-osx

Install go 1.2 from golang.org

Use the binary .pkg installer for go 1.2 (or later) from golang.org. If you choose the defaults, it isn't necessary to set the $GOROOT environment variable, and the go binary will be in your $PATH. You may have to start a new Terminal window to see these changes.

$ brew rm --force go  # if you had go installed via homebrew
$ # (download and double-click on the .pkg installer now)
$ brew install mercurial
$ # The next 2 lines probably should go in ~/.bash_profile or the like
$ export GOPATH=$HOME/Projects/gowork  # or wherever
$ export PATH=$PATH:$GOPATH/bin
$ go version
go version go1.2 darwin/amd64

Check out and build Docker

Docker client and server apparently need to agree exactly on a version string or resource, so ensure that you build your Mac OS X docker client and provision your Linux VM docker server from the same local repository checkout.

$ cd $GOPATH
$ go get -v github.com/dotcloud/docker/docker
$ cd src/github.com/dotcloud/docker
$ git checkout v0.7.2
$ CC=clang go install -a

Create the Vagrant VM

Edit the Vagrantfile in the docker repository (your current directory if you have been following along). Add the following line inside the Vagrant::Config.run block (in v0.7.2, at line 101):

  config.vm.forward_port 4243, 4243

Save the vagrantfile and run vagrant up to create a box running the docker daemon. SSH into the box and sudo edit the /etc/init/docker.conf upstart daemon file and add the -H argument, so the last two lines are like this:

        "$DOCKER" -H tcp://0.0.0.0:4243 -d $DOCKER_OPTS
end script

Now restart the docker daemon:

Now log out, then reboot the VM using vagrant reload so the docker port is exported at 4243.

Connect the client and test

Back in Mac OS X... Rather than specify a host argument each time we invoke docker, let's just set an alias in ~/.bash_profile: alias docker='docker -H tcp://127.0.0.1:4243/'

Then run docker version and you should see this:

Go version (client): go1.2
Server version: 0.7.2
Git commit (server): 88df052
Go version (server): go1.2
Last stable version: 0.7.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment