Install Virtualbox
Install XCode and the Command Line Tools
Install homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Install boot2docker:
brew install boot2docker
Bootstrap boot2docker:
boot2docker init boot2docker up
Add the
DOCKER_HOST
to your profile:echo "export DOCKER_HOST=tcp://$(boot2docker ip 2> /dev/null):2375" >> ~/.bashrc
We will name the VM localdocker
, allowing us to always be able to access
the running containers on whatever port they are exposed.
Update your /etc/hosts
file:
echo "$(boot2docker ip 2> /dev/null) localdocker" | sudo tee --append /etc/hosts
Now when a container is run:
docker run -p 5000:80 nginx
We can connect to the container via `http://localdocker:5000/`_.
Download the boot2docker iso with Virtualbox Guest Additions:
boot2docker down curl http://static.dockerfiles.io/boot2docker-v1.2.0-virtualbox-guest-additions-v4.3.14.iso > ~/.boot2docker/boot2docker.iso
Mount
/Users
into the VM in order to support binding volumes into docker containers:VBoxManage sharedfolder add boot2docker-vm -name home -hostpath /Users
Start boot2docker:
boot2docker up
An appropriate way to inspect a running container is via nsenter
. It
can drop us into a shell inside of the container's filesystem and inspect its
running processes. Unfortunately it only works on linux, so we will create a
docker-enter
script that works for us over ssh.
Build and install
nsenter
. You can run this from the host because the bind-mounting is still only from the VM:docker run --rm -v /var/lib/boot2docker:/target jpetazzo/nsenter
Setup
docker-enter
script for easy inspection in OS X:cat > /usr/local/bin/docker-enter <<'EOF' #!/bin/bash set -e # Check for nsenter. If not found, install it boot2docker ssh '[ -f /var/lib/boot2docker/nsenter ] || docker run --rm -v /var/lib/boot2docker/:/target jpetazzo/nsenter' # Use bash if no command is specified args=$@ if [[ $# = 1 ]]; then args+=(/bin/bash) fi boot2docker ssh -t sudo /var/lib/boot2docker/docker-enter "${args[@]}" EOF chmod +x /usr/local/bin/docker-enter
Great info.
For BSD tee (by default on OS X) the command in "Setup DNS" should use -a for append (not --append) i.e: