2014-05-05 10:42:23 -04:00
|
|
|
page_title: Installation on Mac OS X
|
|
|
|
page_description: Instructions for installing Docker on OS X using boot2docker.
|
|
|
|
page_keywords: Docker, Docker documentation, requirements, boot2docker, VirtualBox, SSH, Linux, OSX, OS X, Mac
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
# Installing Docker on Mac OS X
|
2014-04-18 16:21:55 -04:00
|
|
|
|
|
|
|
> **Note**:
|
2014-04-23 16:48:28 -04:00
|
|
|
> Docker is still under heavy development! We don't recommend using it in
|
|
|
|
> production yet, but we're getting closer with each release. Please see
|
2014-04-18 16:21:55 -04:00
|
|
|
> our blog post, [Getting to Docker 1.0](
|
|
|
|
> http://blog.docker.io/2013/08/getting-to-docker-1-0/)
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
> **Note:**
|
|
|
|
> Docker is supported on Mac OS X 10.6 "Snow Leopard" or newer.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
Docker has two key components: the Docker daemon and the `docker` binary
|
|
|
|
which acts as a client. The client passes instructions to the daemon
|
|
|
|
which builds, runs and manages your Docker containers. As Docker uses
|
|
|
|
some Linux-specific kernel features you can't use it directly on OS X.
|
|
|
|
Instead we run the Docker daemon inside a lightweight virtual machine on your local
|
|
|
|
OS X host. We can then use a native client `docker` binary to communicate
|
|
|
|
with the Docker daemon inside our virtual machine. To make this process
|
|
|
|
easier we've designed a helper application called
|
|
|
|
[boot2docker](https://github.com/boot2docker/boot2docker) to install
|
|
|
|
that virtual machine and run our Docker daemon.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
[boot2docker](https://github.com/boot2docker/boot2docker) uses
|
|
|
|
VirtualBox to create the virtual machine so we'll need to install that
|
|
|
|
first.
|
|
|
|
|
|
|
|
## Installing VirtualBox
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
Docker on OS X needs VirtualBox to run. To begin with, head over to
|
|
|
|
[VirtualBox Download Page](https://www.virtualbox.org/wiki/Downloads)
|
|
|
|
and get the tool for `OS X hosts x86/amd64`.
|
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
Once the download is complete, open the disk image, run `VirtualBox.pkg`
|
|
|
|
and install VirtualBox.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
> **Note**:
|
|
|
|
> Do not simply copy the package without running the
|
|
|
|
> installer.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-09 00:18:03 -04:00
|
|
|
## Installing boot2docker manually
|
2014-05-05 10:42:23 -04:00
|
|
|
|
2014-05-09 00:18:03 -04:00
|
|
|
### Downloading the boot2docker script
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
[boot2docker](https://github.com/boot2docker/boot2docker) provides a
|
|
|
|
handy script to manage the VM running the Docker daemon. It also takes
|
|
|
|
care of the installation of that VM.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
Open up a new terminal window and run the following commands to get
|
|
|
|
boot2docker:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
# Enter the installation directory
|
2014-05-05 10:42:23 -04:00
|
|
|
$ mkdir -p ~/bin
|
2014-05-01 10:13:34 -04:00
|
|
|
$ cd ~/bin
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
# Get the file
|
2014-05-05 08:52:12 -04:00
|
|
|
$ curl https://raw.githubusercontent.com/boot2docker/boot2docker/master/boot2docker > boot2docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
# Mark it executable
|
2014-05-01 10:13:34 -04:00
|
|
|
$ chmod +x boot2docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
### Installing the Docker OS X Client
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
The Docker daemon is accessed using the `docker` binary.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
Run the following commands to get it downloaded and set up:
|
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
# Get the docker binary
|
2014-05-01 10:13:34 -04:00
|
|
|
$ DIR=$(mktemp -d ${TMPDIR:-/tmp}/dockerdl.XXXXXXX) && \
|
2014-05-05 08:52:12 -04:00
|
|
|
curl -f -o $DIR/ld.tgz https://get.docker.io/builds/Darwin/x86_64/docker-latest.tgz && \
|
|
|
|
gunzip $DIR/ld.tgz && \
|
|
|
|
tar xvf $DIR/ld.tar -C $DIR/ && \
|
|
|
|
cp $DIR/usr/local/bin/docker ./docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
# Copy the executable file
|
2014-05-01 10:13:34 -04:00
|
|
|
$ sudo mkdir -p /usr/local/bin
|
|
|
|
$ sudo cp docker /usr/local/bin/
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
### Configure the Docker OS X Client
|
|
|
|
|
|
|
|
The Docker client, `docker`, uses an environment variable `DOCKER_HOST`
|
|
|
|
to specify the location of the Docker daemon to connect to. Specify your
|
|
|
|
local boot2docker virtual machine as the value of that variable.
|
|
|
|
|
|
|
|
$ export DOCKER_HOST=tcp://127.0.0.1:4243
|
|
|
|
|
|
|
|
## Installing boot2docker with Homebrew
|
2014-05-05 08:52:12 -04:00
|
|
|
|
|
|
|
If you are using Homebrew on your machine, simply run the following
|
|
|
|
command to install `boot2docker`:
|
|
|
|
|
|
|
|
$ brew install boot2docker
|
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
Run the following command to install the Docker client:
|
2014-05-05 08:52:12 -04:00
|
|
|
|
|
|
|
$ brew install docker
|
|
|
|
|
2014-04-23 16:48:28 -04:00
|
|
|
And that's it! Let's check out how to use it.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
# How To Use Docker On Mac OS X
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
## Running the Docker daemon via boot2docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
Firstly we need to initialize our boot2docker virtual machine. Run the
|
|
|
|
`boot2docker` command.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
$ boot2docker init
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
This will setup our initial virtual machine.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
Next we need to start the Docker daemon.
|
|
|
|
|
|
|
|
$ boot2docker up
|
|
|
|
|
|
|
|
There are a variety of others commands available using the `boot2docker`
|
|
|
|
script. You can see these like so:
|
|
|
|
|
|
|
|
$ boot2docker
|
2014-05-05 08:52:12 -04:00
|
|
|
Usage ./boot2docker {init|start|up|pause|stop|restart|status|info|delete|ssh|download}
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
## The Docker client
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
Once the virtual machine with the Docker daemon is up, you can use the `docker`
|
|
|
|
binary just like any other application.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-01 10:13:34 -04:00
|
|
|
$ docker version
|
2014-05-05 08:52:12 -04:00
|
|
|
Client version: 0.10.0
|
|
|
|
Client API version: 1.10
|
|
|
|
Server version: 0.10.0
|
|
|
|
Server API version: 1.10
|
|
|
|
Last stable version: 0.10.0
|
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
## Using Docker port forwarding with boot2docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
In order to forward network ports from Docker with boot2docker we need to
|
|
|
|
manually forward the port range Docker uses inside VirtualBox. To do
|
|
|
|
this we take the port range that Docker uses by default with the `-P`
|
|
|
|
option, ports 49000-49900, and run the following command.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
> **Note:**
|
|
|
|
> The boot2docker virtual machine must be powered off for this
|
|
|
|
> to work.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
for i in {49000..49900}; do
|
|
|
|
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
|
|
|
|
VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
|
|
|
|
done
|
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
## Connecting to the VM via SSH
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
If you feel the need to connect to the VM, you can simply run:
|
|
|
|
|
2014-05-01 10:13:34 -04:00
|
|
|
$ ./boot2docker ssh
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
# User: docker
|
|
|
|
# Pwd: tcuser
|
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
If SSH complains about keys then run:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
$ ssh-keygen -R '[localhost]:2022'
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
## Upgrading to a newer release of boot2docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
To upgrade an initialized boot2docker virtual machine, you can use the
|
|
|
|
following 3 commands. Your virtual machine's disk will not be changed,
|
|
|
|
so you won't lose your images and containers:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
$ boot2docker stop
|
|
|
|
$ boot2docker download
|
|
|
|
$ boot2docker start
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
# Learn More
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
## boot2docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
See the GitHub page for
|
|
|
|
[boot2docker](https://github.com/boot2docker/boot2docker).
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
# Next steps
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-05-05 10:42:23 -04:00
|
|
|
You can now continue with the [*Hello
|
|
|
|
World*](/examples/hello_world/#hello-world) example.
|
2014-04-15 20:53:12 -04:00
|
|
|
|