Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)
| ... | ... |
@@ -1,12 +1,8 @@ |
| 1 |
-page_title: Installation on Mac OS X 10.6 Snow Leopard |
|
| 2 |
-page_description: Please note this project is currently under heavy development. It should not be used in production. |
|
| 3 |
-page_keywords: Docker, Docker documentation, requirements, virtualbox, ssh, linux, os x, osx, mac |
|
| 1 |
+page_title: Installation on Mac OS X |
|
| 2 |
+page_description: Instructions for installing Docker on OS X using boot2docker. |
|
| 3 |
+page_keywords: Docker, Docker documentation, requirements, boot2docker, VirtualBox, SSH, Linux, OSX, OS X, Mac |
|
| 4 | 4 |
|
| 5 |
-# Mac OS X |
|
| 6 |
- |
|
| 7 |
-> **Note**: |
|
| 8 |
-> These instructions are available with the new release of Docker (version |
|
| 9 |
-> 0.8). However, they are subject to change. |
|
| 5 |
+# Installing Docker on Mac OS X |
|
| 10 | 6 |
|
| 11 | 7 |
> **Note**: |
| 12 | 8 |
> Docker is still under heavy development! We don't recommend using it in |
| ... | ... |
@@ -14,33 +10,50 @@ page_keywords: Docker, Docker documentation, requirements, virtualbox, ssh, linu |
| 14 | 14 |
> our blog post, [Getting to Docker 1.0]( |
| 15 | 15 |
> http://blog.docker.io/2013/08/getting-to-docker-1-0/) |
| 16 | 16 |
|
| 17 |
-Docker is supported on Mac OS X 10.6 "Snow Leopard" or newer. |
|
| 17 |
+> **Note:** |
|
| 18 |
+> Docker is supported on Mac OS X 10.6 "Snow Leopard" or newer. |
|
| 18 | 19 |
|
| 19 |
-## How To Install Docker On Mac OS X |
|
| 20 |
+Docker has two key components: the Docker daemon and the `docker` binary |
|
| 21 |
+which acts as a client. The client passes instructions to the daemon |
|
| 22 |
+which builds, runs and manages your Docker containers. As Docker uses |
|
| 23 |
+some Linux-specific kernel features you can't use it directly on OS X. |
|
| 24 |
+Instead we run the Docker daemon inside a lightweight virtual machine on your local |
|
| 25 |
+OS X host. We can then use a native client `docker` binary to communicate |
|
| 26 |
+with the Docker daemon inside our virtual machine. To make this process |
|
| 27 |
+easier we've designed a helper application called |
|
| 28 |
+[boot2docker](https://github.com/boot2docker/boot2docker) to install |
|
| 29 |
+that virtual machine and run our Docker daemon. |
|
| 20 | 30 |
|
| 21 |
-### VirtualBox |
|
| 31 |
+[boot2docker](https://github.com/boot2docker/boot2docker) uses |
|
| 32 |
+VirtualBox to create the virtual machine so we'll need to install that |
|
| 33 |
+first. |
|
| 34 |
+ |
|
| 35 |
+## Installing VirtualBox |
|
| 22 | 36 |
|
| 23 | 37 |
Docker on OS X needs VirtualBox to run. To begin with, head over to |
| 24 | 38 |
[VirtualBox Download Page](https://www.virtualbox.org/wiki/Downloads) |
| 25 | 39 |
and get the tool for `OS X hosts x86/amd64`. |
| 26 | 40 |
|
| 27 |
-Once the download is complete, open the disk image, run the set up file |
|
| 28 |
-(i.e. `VirtualBox.pkg`) and install VirtualBox. Do |
|
| 29 |
-not simply copy the package without running the installer. |
|
| 41 |
+Once the download is complete, open the disk image, run `VirtualBox.pkg` |
|
| 42 |
+and install VirtualBox. |
|
| 30 | 43 |
|
| 31 |
-### Manual Installation |
|
| 32 |
-#### boot2docker |
|
| 44 |
+> **Note**: |
|
| 45 |
+> Do not simply copy the package without running the |
|
| 46 |
+> installer. |
|
| 33 | 47 |
|
| 34 |
-[boot2docker](https://github.com/boot2docker/boot2docker) provides a |
|
| 35 |
-handy script to manage the VM running the `docker` |
|
| 36 |
-daemon. It also takes care of the installation for the OS |
|
| 37 |
-image that is used for the job. |
|
| 48 |
+## Installing boot2docker |
|
| 49 |
+ |
|
| 50 |
+### Installing manually |
|
| 38 | 51 |
|
| 39 |
-Open up a new terminal window, if you have not already. |
|
| 52 |
+[boot2docker](https://github.com/boot2docker/boot2docker) provides a |
|
| 53 |
+handy script to manage the VM running the Docker daemon. It also takes |
|
| 54 |
+care of the installation of that VM. |
|
| 40 | 55 |
|
| 41 |
-Run the following commands to get boot2docker: |
|
| 56 |
+Open up a new terminal window and run the following commands to get |
|
| 57 |
+boot2docker: |
|
| 42 | 58 |
|
| 43 | 59 |
# Enter the installation directory |
| 60 |
+ $ mkdir -p ~/bin |
|
| 44 | 61 |
$ cd ~/bin |
| 45 | 62 |
|
| 46 | 63 |
# Get the file |
| ... | ... |
@@ -49,62 +62,69 @@ Run the following commands to get boot2docker: |
| 49 | 49 |
# Mark it executable |
| 50 | 50 |
$ chmod +x boot2docker |
| 51 | 51 |
|
| 52 |
-#### Docker OS X Client |
|
| 52 |
+### Installing the Docker OS X Client |
|
| 53 | 53 |
|
| 54 |
-The `docker` daemon is accessed using the `docker` client. |
|
| 54 |
+The Docker daemon is accessed using the `docker` binary. |
|
| 55 | 55 |
|
| 56 | 56 |
Run the following commands to get it downloaded and set up: |
| 57 | 57 |
|
| 58 |
- # Get the docker client file |
|
| 58 |
+ # Get the docker binary |
|
| 59 | 59 |
$ DIR=$(mktemp -d ${TMPDIR:-/tmp}/dockerdl.XXXXXXX) && \
|
| 60 | 60 |
curl -f -o $DIR/ld.tgz https://get.docker.io/builds/Darwin/x86_64/docker-latest.tgz && \ |
| 61 | 61 |
gunzip $DIR/ld.tgz && \ |
| 62 | 62 |
tar xvf $DIR/ld.tar -C $DIR/ && \ |
| 63 | 63 |
cp $DIR/usr/local/bin/docker ./docker |
| 64 | 64 |
|
| 65 |
- # Set the environment variable for the docker daemon |
|
| 66 |
- $ export DOCKER_HOST=tcp://127.0.0.1:4243 |
|
| 67 |
- |
|
| 68 | 65 |
# Copy the executable file |
| 69 | 66 |
$ sudo mkdir -p /usr/local/bin |
| 70 | 67 |
$ sudo cp docker /usr/local/bin/ |
| 71 | 68 |
|
| 72 |
-### (OR) With Homebrew |
|
| 69 |
+### Configure the Docker OS X Client |
|
| 70 |
+ |
|
| 71 |
+The Docker client, `docker`, uses an environment variable `DOCKER_HOST` |
|
| 72 |
+to specify the location of the Docker daemon to connect to. Specify your |
|
| 73 |
+local boot2docker virtual machine as the value of that variable. |
|
| 74 |
+ |
|
| 75 |
+ $ export DOCKER_HOST=tcp://127.0.0.1:4243 |
|
| 76 |
+ |
|
| 77 |
+## Installing boot2docker with Homebrew |
|
| 73 | 78 |
|
| 74 | 79 |
If you are using Homebrew on your machine, simply run the following |
| 75 | 80 |
command to install `boot2docker`: |
| 76 | 81 |
|
| 77 | 82 |
$ brew install boot2docker |
| 78 | 83 |
|
| 79 |
-Run the following command to install the `docker` |
|
| 80 |
-client: |
|
| 84 |
+Run the following command to install the Docker client: |
|
| 81 | 85 |
|
| 82 | 86 |
$ brew install docker |
| 83 | 87 |
|
| 84 | 88 |
And that's it! Let's check out how to use it. |
| 85 | 89 |
|
| 86 |
-## How To Use Docker On Mac OS X |
|
| 90 |
+# How To Use Docker On Mac OS X |
|
| 87 | 91 |
|
| 88 |
-### The `docker` daemon (via boot2docker) |
|
| 92 |
+## Running the Docker daemon via boot2docker |
|
| 89 | 93 |
|
| 90 |
-Inside the `~/bin` directory, run the following |
|
| 91 |
-commands: |
|
| 94 |
+Firstly we need to initialize our boot2docker virtual machine. Run the |
|
| 95 |
+`boot2docker` command. |
|
| 92 | 96 |
|
| 93 |
- # Initiate the VM |
|
| 94 |
- $ ./boot2docker init |
|
| 97 |
+ $ boot2docker init |
|
| 95 | 98 |
|
| 96 |
- # Run the VM (the docker daemon) |
|
| 97 |
- $ ./boot2docker up |
|
| 99 |
+This will setup our initial virtual machine. |
|
| 98 | 100 |
|
| 99 |
- # To see all available commands: |
|
| 100 |
- $ ./boot2docker |
|
| 101 |
+Next we need to start the Docker daemon. |
|
| 102 |
+ |
|
| 103 |
+ $ boot2docker up |
|
| 104 |
+ |
|
| 105 |
+There are a variety of others commands available using the `boot2docker` |
|
| 106 |
+script. You can see these like so: |
|
| 107 |
+ |
|
| 108 |
+ $ boot2docker |
|
| 101 | 109 |
Usage ./boot2docker {init|start|up|pause|stop|restart|status|info|delete|ssh|download}
|
| 102 | 110 |
|
| 103 |
-### The `docker` client |
|
| 111 |
+## The Docker client |
|
| 104 | 112 |
|
| 105 |
-Once the VM with the `docker` daemon is up, you can |
|
| 106 |
-use the `docker` client just like any other |
|
| 107 |
-application. |
|
| 113 |
+Once the virtual machine with the Docker daemon is up, you can use the `docker` |
|
| 114 |
+binary just like any other application. |
|
| 108 | 115 |
|
| 109 | 116 |
$ docker version |
| 110 | 117 |
Client version: 0.10.0 |
| ... | ... |
@@ -113,20 +133,23 @@ application. |
| 113 | 113 |
Server API version: 1.10 |
| 114 | 114 |
Last stable version: 0.10.0 |
| 115 | 115 |
|
| 116 |
+## Using Docker port forwarding with boot2docker |
|
| 116 | 117 |
|
| 117 |
-### Forwarding VM Port Range to Host |
|
| 118 |
+In order to forward network ports from Docker with boot2docker we need to |
|
| 119 |
+manually forward the port range Docker uses inside VirtualBox. To do |
|
| 120 |
+this we take the port range that Docker uses by default with the `-P` |
|
| 121 |
+option, ports 49000-49900, and run the following command. |
|
| 118 | 122 |
|
| 119 |
-If we take the port range that docker uses by default with the -P option |
|
| 120 |
-(49000-49900), and forward same range from host to vm, we'll be able to |
|
| 121 |
-interact with our containers as if they were running locally: |
|
| 123 |
+> **Note:** |
|
| 124 |
+> The boot2docker virtual machine must be powered off for this |
|
| 125 |
+> to work. |
|
| 122 | 126 |
|
| 123 |
- # vm must be powered off |
|
| 124 | 127 |
for i in {49000..49900}; do
|
| 125 | 128 |
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i"; |
| 126 | 129 |
VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i"; |
| 127 | 130 |
done |
| 128 | 131 |
|
| 129 |
-### SSH-ing The VM |
|
| 132 |
+## Connecting to the VM via SSH |
|
| 130 | 133 |
|
| 131 | 134 |
If you feel the need to connect to the VM, you can simply run: |
| 132 | 135 |
|
| ... | ... |
@@ -135,37 +158,29 @@ If you feel the need to connect to the VM, you can simply run: |
| 135 | 135 |
# User: docker |
| 136 | 136 |
# Pwd: tcuser |
| 137 | 137 |
|
| 138 |
-You can now continue with the [*Hello |
|
| 139 |
-World*](/examples/hello_world/#hello-world) example. |
|
| 138 |
+If SSH complains about keys then run: |
|
| 140 | 139 |
|
| 141 |
-## Learn More |
|
| 140 |
+ $ ssh-keygen -R '[localhost]:2022' |
|
| 142 | 141 |
|
| 143 |
-### boot2docker: |
|
| 142 |
+## Upgrading to a newer release of boot2docker |
|
| 144 | 143 |
|
| 145 |
-See the GitHub page for |
|
| 146 |
-[boot2docker](https://github.com/boot2docker/boot2docker). |
|
| 144 |
+To upgrade an initialized boot2docker virtual machine, you can use the |
|
| 145 |
+following 3 commands. Your virtual machine's disk will not be changed, |
|
| 146 |
+so you won't lose your images and containers: |
|
| 147 | 147 |
|
| 148 |
-### If SSH complains about keys: |
|
| 148 |
+ $ boot2docker stop |
|
| 149 |
+ $ boot2docker download |
|
| 150 |
+ $ boot2docker start |
|
| 149 | 151 |
|
| 150 |
- $ ssh-keygen -R '[localhost]:2022' |
|
| 152 |
+# Learn More |
|
| 151 | 153 |
|
| 152 |
-### Upgrading to a newer release of boot2docker |
|
| 154 |
+## boot2docker |
|
| 153 | 155 |
|
| 154 |
-To upgrade an initialised VM, you can use the following 3 commands. Your |
|
| 155 |
-persistence disk will not be changed, so you won't lose your images and |
|
| 156 |
-containers: |
|
| 156 |
+See the GitHub page for |
|
| 157 |
+[boot2docker](https://github.com/boot2docker/boot2docker). |
|
| 157 | 158 |
|
| 158 |
- $ ./boot2docker stop |
|
| 159 |
- $ ./boot2docker download |
|
| 160 |
- $ ./boot2docker start |
|
| 159 |
+# Next steps |
|
| 161 | 160 |
|
| 162 |
-### About the way Docker works on Mac OS X: |
|
| 161 |
+You can now continue with the [*Hello |
|
| 162 |
+World*](/examples/hello_world/#hello-world) example. |
|
| 163 | 163 |
|
| 164 |
-Docker has two key components: the `docker` daemon and the `docker` client. |
|
| 165 |
-The tool works by client commanding the daemon. In order to work and do its |
|
| 166 |
-magic, the daemon makes use of some Linux Kernel features (e.g. LXC, name |
|
| 167 |
-spaces etc.), which are not supported by OS X. Therefore, the solution of |
|
| 168 |
-getting Docker to run on OS X consists of running it inside a lightweight |
|
| 169 |
-virtual machine. In order to simplify things, Docker comes with a bash |
|
| 170 |
-script to make this whole process as easy as possible (i.e. |
|
| 171 |
-boot2docker). |