Skip to content

Instantly share code, notes, and snippets.

@jpancoast
Last active December 13, 2015 03:50
Show Gist options
  • Save jpancoast/194ac0ae092c4c2dddc8 to your computer and use it in GitHub Desktop.
Save jpancoast/194ac0ae092c4c2dddc8 to your computer and use it in GitHub Desktop.
Running Docker on coreos using Vagrant on OS X

Slightly Modified from here: http://www.siliconfidential.com/articles/docker-coreos-osx/ with some additions from: https://coreos.com/os/docs/latest/customizing-docker.html

wget http://get.docker.io/builds/Darwin/x86_64/docker-latest
chmod +x docker-latest
sudo mv docker-latest /usr/local/bin/docker

Now get the fancy Vagrantfile from the original folks:

git clone https://github.com/coreos/coreos-vagrant/
cd coreos-vagrant

This is where these instructions diverge from the original.

Edit Vagrantfile

If you want to share folders between the host and the guest:

$shared_folders = {'/path/on/host' => '/path/on/guest', '/home/foo/app' => '/app'}

Forward the docker tcp port to the guest so your local docker client can connect (you will have to add this line):

$expose_docker_tcp=2375

Forward any other ports:

$forwarded_ports = { port_on_host => port_on_guest, port_on_host => port_on_guest }

Bring the box up (You will be prompted for your admin password so it can nfs mount the shared directories):

vagrant up

Connect to the box:

vagrant ssh

Create a file on the vagrant box /etc/systemd/system/docker-tcp.socket:

[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=2375
BindIPv6Only=both
Service=docker.service

[Install]
WantedBy=sockets.target

Enable docker and the port listening:

sudo systemctl enable docker-tcp.socket
sudo systemctl stop docker
sudo systemctl start docker-tcp.socket
sudo systemctl start docker

Now from your mac:

export DOCKER_HOST=127.0.0.1:2375

Did it work (From the mac command line)?

docker run ubuntu /bin/echo hello world
docker ps -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment