github.com/codemac/docker@v1.2.1-0.20150518222241-6a18412d5b9c/docs/sources/installation/mac.md (about) 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 5 # Mac OS X 6 7 You can install Docker using Boot2Docker to run `docker` commands at your command-line. 8 Choose this installation if you are familiar with the command-line or plan to 9 contribute to the Docker project on GitHub. 10 11 Alternatively, you may want to try <a id="inlinelink" href="https://kitematic.com/" 12 target="_blank">Kitematic</a>, an application that lets you set up Docker and 13 run containers using a graphical user interface (GUI). 14 15 <a id="graphic" href="https://kitematic.com/" target="_blank"><img 16 src="/installation/images/kitematic.png" alt="Download Kitematic"></a> 17 18 19 ## Command-line Docker with Boot2Docker 20 21 Because the Docker daemon uses Linux-specific kernel features, you can't run 22 Docker natively in OS X. Instead, you must install the Boot2Docker application. 23 The application includes a VirtualBox Virtual Machine (VM), Docker itself, and the 24 Boot2Docker management tool. 25 26 The Boot2Docker management tool is a lightweight Linux virtual machine made 27 specifically to run the Docker daemon on Mac OS X. The VirtualBox VM runs 28 completely from RAM, is a small ~24MB download, and boots in approximately 5s. 29 30 **Requirements** 31 32 Your Mac must be running OS X 10.6 "Snow Leopard" or newer to run Boot2Docker. 33 34 ### Learn the key concepts before installing 35 36 In a Docker installation on Linux, your machine is both the localhost and the 37 Docker host. In networking, localhost means your computer. The Docker host is 38 the machine on which the containers run. 39 40 On a typical Linux installation, the Docker client, the Docker daemon, and any 41 containers run directly on your localhost. This means you can address ports on a 42 Docker container using standard localhost addressing such as `localhost:8000` or 43 `0.0.0.0:8376`. 44 45  46 47 In an OS X installation, the `docker` daemon is running inside a Linux virtual 48 machine provided by Boot2Docker. 49 50  51 52 In OS X, the Docker host address is the address of the Linux VM. 53 When you start the `boot2docker` process, the VM is assigned an IP address. Under 54 `boot2docker` ports on a container map to ports on the VM. To see this in 55 practice, work through the exercises on this page. 56 57 58 ### Installation 59 60 1. Go to the [boot2docker/osx-installer ]( 61 https://github.com/boot2docker/osx-installer/releases/latest) release page. 62 63 4. Download Boot2Docker by clicking `Boot2Docker-x.x.x.pkg` in the "Downloads" 64 section. 65 66 3. Install Boot2Docker by double-clicking the package. 67 68 The installer places Boot2Docker in your "Applications" folder. 69 70 The installation places the `docker` and `boot2docker` binaries in your 71 `/usr/local/bin` directory. 72 73 74 ## Start the Boot2Docker Application 75 76 To run a Docker container, you first start the `boot2docker` VM and then issue 77 `docker` commands to create, load, and manage containers. You can launch 78 `boot2docker` from your Applications folder or from the command line. 79 80 > **NOTE**: Boot2Docker is designed as a development tool. You should not use 81 > it in production environments. 82 83 ### From the Applications folder 84 85 When you launch the "Boot2Docker" application from your "Applications" folder, the 86 application: 87 88 * opens a terminal window 89 90 * creates a $HOME/.boot2docker directory 91 92 * creates a VirtualBox ISO and certs 93 94 * starts a VirtualBox VM running the `docker` daemon 95 96 Once the launch completes, you can run `docker` commands. A good way to verify 97 your setup succeeded is to run the `hello-world` container. 98 99 $ docker run hello-world 100 Unable to find image 'hello-world:latest' locally 101 511136ea3c5a: Pull complete 102 31cbccb51277: Pull complete 103 e45a5af57b00: Pull complete 104 hello-world:latest: The image you are pulling has been verified. 105 Important: image verification is a tech preview feature and should not be 106 relied on to provide security. 107 Status: Downloaded newer image for hello-world:latest 108 Hello from Docker. 109 This message shows that your installation appears to be working correctly. 110 111 To generate this message, Docker took the following steps: 112 1. The Docker client contacted the Docker daemon. 113 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 114 (Assuming it was not already locally available.) 115 3. The Docker daemon created a new container from that image which runs the 116 executable that produces the output you are currently reading. 117 4. The Docker daemon streamed that output to the Docker client, which sent it 118 to your terminal. 119 120 To try something more ambitious, you can run an Ubuntu container with: 121 $ docker run -it ubuntu bash 122 123 For more examples and ideas, visit: 124 http://docs.docker.com/userguide/ 125 126 127 A more typical way to start and stop `boot2docker` is using the command line. 128 129 ### From your command line 130 131 Initialize and run `boot2docker` from the command line, do the following: 132 133 1. Create a new Boot2Docker VM. 134 135 $ boot2docker init 136 137 This creates a new virtual machine. You only need to run this command once. 138 139 2. Start the `boot2docker` VM. 140 141 $ boot2docker start 142 143 3. Display the environment variables for the Docker client. 144 145 $ boot2docker shellinit 146 Writing /Users/mary/.boot2docker/certs/boot2docker-vm/ca.pem 147 Writing /Users/mary/.boot2docker/certs/boot2docker-vm/cert.pem 148 Writing /Users/mary/.boot2docker/certs/boot2docker-vm/key.pem 149 export DOCKER_HOST=tcp://192.168.59.103:2376 150 export DOCKER_CERT_PATH=/Users/mary/.boot2docker/certs/boot2docker-vm 151 export DOCKER_TLS_VERIFY=1 152 153 The specific paths and address on your machine will be different. 154 155 4. To set the environment variables in your shell do the following: 156 157 $ eval "$(boot2docker shellinit)" 158 159 You can also set them manually by using the `export` commands `boot2docker` 160 returns. 161 162 5. Run the `hello-world` container to verify your setup. 163 164 $ docker run hello-world 165 166 167 ## Basic Boot2Docker exercises 168 169 At this point, you should have `boot2docker` running and the `docker` client 170 environment initialized. To verify this, run the following commands: 171 172 $ boot2docker status 173 $ docker version 174 175 Work through this section to try some practical container tasks using `boot2docker` VM. 176 177 ### Access container ports 178 179 1. Start an NGINX container on the DOCKER_HOST. 180 181 $ docker run -d -P --name web nginx 182 183 Normally, the `docker run` commands starts a container, runs it, and then 184 exits. The `-d` flag keeps the container running in the background 185 after the `docker run` command completes. The `-P` flag publishes exposed ports from the 186 container to your local host; this lets you access them from your Mac. 187 188 2. Display your running container with `docker ps` command 189 190 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 191 5fb65ff765e9 nginx:latest "nginx -g 'daemon of 3 minutes ago Up 3 minutes 0.0.0.0:49156->443/tcp, 0.0.0.0:49157->80/tcp web 192 193 At this point, you can see `nginx` is running as a daemon. 194 195 3. View just the container's ports. 196 197 $ docker port web 198 443/tcp -> 0.0.0.0:49156 199 80/tcp -> 0.0.0.0:49157 200 201 This tells you that the `web` container's port `80` is mapped to port 202 `49157` on your Docker host. 203 204 4. Enter the `http://localhost:49157` address (`localhost` is `0.0.0.0`) in your browser: 205 206  207 208 This didn't work. The reason it doesn't work is your `DOCKER_HOST` address is 209 not the localhost address (0.0.0.0) but is instead the address of the 210 `boot2docker` VM. 211 212 5. Get the address of the `boot2docker` VM. 213 214 $ boot2docker ip 215 192.168.59.103 216 217 6. Enter the `http://192.168.59.103:49157` address in your browser: 218 219  220 221 Success! 222 223 7. To stop and then remove your running `nginx` container, do the following: 224 225 $ docker stop web 226 $ docker rm web 227 228 ### Mount a volume on the container 229 230 When you start `boot2docker`, it automatically shares your `/Users` directory 231 with the VM. You can use this share point to mount directories onto your container. 232 The next exercise demonstrates how to do this. 233 234 1. Change to your user `$HOME` directory. 235 236 $ cd $HOME 237 238 2. Make a new `site` directory. 239 240 $ mkdir site 241 242 3. Change into the `site` directory. 243 244 $ cd site 245 246 4. Create a new `index.html` file. 247 248 $ echo "my new site" > index.html 249 250 5. Start a new `nginx` container and replace the `html` folder with your `site` directory. 251 252 $ docker run -d -P -v $HOME/site:/usr/share/nginx/html --name mysite nginx 253 254 6. Get the `mysite` container's port. 255 256 $ docker port mysite 257 80/tcp -> 0.0.0.0:49166 258 443/tcp -> 0.0.0.0:49165 259 260 7. Open the site in a browser: 261 262  263 264 8. Try adding a page to your `$HOME/site` in real time. 265 266 $ echo "This is cool" > cool.html 267 268 9. Open the new page in the browser. 269 270  271 272 9. Stop and then remove your running `mysite` container. 273 274 $ docker stop mysite 275 $ docker rm mysite 276 277 ## Upgrade Boot2Docker 278 279 If you running Boot2Docker 1.4.1 or greater, you can upgrade Boot2Docker from 280 the command line. If you are running an older version, you should use the 281 package provided by the `boot2docker` repository. 282 283 ### From the command line 284 285 To upgrade from 1.4.1 or greater, you can do this: 286 287 1. Open a terminal on your local machine. 288 289 2. Stop the `boot2docker` application. 290 291 $ boot2docker stop 292 293 3. Run the upgrade command. 294 295 $ boot2docker upgrade 296 297 298 ### Use the installer 299 300 To upgrade any version of Boot2Docker, do this: 301 302 1. Open a terminal on your local machine. 303 304 2. Stop the `boot2docker` application. 305 306 $ boot2docker stop 307 308 3. Go to the [boot2docker/osx-installer ]( 309 https://github.com/boot2docker/osx-installer/releases/latest) release page. 310 311 4. Download Boot2Docker by clicking `Boot2Docker-x.x.x.pkg` in the "Downloads" 312 section. 313 314 2. Install Boot2Docker by double-clicking the package. 315 316 The installer places Boot2Docker in your "Applications" folder. 317 318 319 ## Uninstallation 320 321 1. Go to the [boot2docker/osx-installer ]( 322 https://github.com/boot2docker/osx-installer/releases/latest) release page. 323 324 2. Download the source code by clicking `Source code (zip)` or 325 `Source code (tar.gz)` in the "Downloads" section. 326 327 3. Extract the source code. 328 329 4. Open a terminal on your local machine. 330 331 5. Change to the directory where you extracted the source code: 332 333 $ cd <path to extracted source code> 334 335 6. Make sure the uninstall.sh script is executable: 336 337 $ chmod +x uninstall.sh 338 339 7. Run the uninstall.sh script: 340 341 $ ./uninstall.sh 342 343 344 ## Learning more and acknowledgement 345 346 Use `boot2docker help` to list the full command line reference. For more 347 information about using SSH or SCP to access the Boot2Docker VM, see the README 348 at [Boot2Docker repository](https://github.com/boot2docker/boot2docker). 349 350 Thanks to Chris Jones whose [blog](http://goo.gl/Be6cCk) inspired me to redo 351 this page. 352 353 Continue with the [Docker User Guide](/userguide/).