yasuoza diary

web and life

Docker in OSX without dvm

Docker client for OSX released as of 0.7.3

Now, we OSX user can access docker container without ssh command by followlig without dvm

Install docker client via Homebrew:

1
2
3
$ brew update
$ brew tap homebrew/binary
$ brew install docker

Next, setup Vagrantfile like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
DOCKER_IP   = ENV["DOCKER_IP"]   || "192.168.42.43"
DOCKER_PORT = ENV["DOCKER_PORT"] || 4243

Vagrant.configure("2") do |config|
  config.vm.box     = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
  config.vm.network :private_network, ip: DOCKER_IP
  config.vm.provision :docker do |d|
    d.pull_images "base"
  end
  config.vm.provision :shell, inline: <<-SHELL
    sudo sed -i -e 's/DOCKER_OPTS=/DOCKER_OPTS=\"-H #{DOCKER_IP}:#{DOCKER_PORT}\"/g' /etc/init/docker.conf
    sudo service docker restart
  SHELL
end

Then run VM:

1
$ vagrant up

Export DOCKER_HOST:

1
$ export DOCKER_HOST="tcp://192.168.42.43:4243" # DOCKER_HOST="$DOCKER_IP:$DOCKER_PORT"

That’s all. Now you can access docker container like:

1
$ docker run base echo "hello world!"

Comments