(I'm not familiar with installation onto a Linux machine. Please follow the instructions on the Docker Installation page.)
[ ] If you're using OS X go directly to the boot2docker installation page, download the latest Boot2Docker pkg
and install it on your laptop. This will install both Docker and Boot2Docker. The Docker installations docs have the following to say about Boot2Docker, which solves the issue for OS X users that Docker must be run on a host system with a Linux kernel.
Because the Docker daemon uses Linux-specific kernel features, you can't run Docker natively in OS X. Instead, you must install the Boot2Docker application. The application includes a VirtualBox Virtual Machine (VM), Docker itself, and the Boot2Docker management tool.
The Boot2Docker management tool is a lightweight Linux virtual machine made specifically to run the Docker daemon on Mac OS X.
The following images, also from the Docker docs, are very helpful in understanding the difference between running Docker on a Linux machine, and running it on OS X by way of Boot2Docker:
[ ] Run the following 3 commands in the terminal
boot2docker init
boot2docker start
$(boot2docker shellinit)
That last command sets environment variables you need to use Docker with Boot2Docker effectively. I recommend adding it to your .bash_profile
(or whatever rc
file your shell loads) so you don't have to worry about running it every time you want to use Docker in a new terminal session. You can easily do that with
echo '$(boot2docker shellinit 2> /dev/null)' >> ~/.bash_profile
which will append the command to the end of your .bash_profile
(be sure to change the filename if you use a differenct rc
file) and redirect the output into the null device 2> /dev/null
so that your don't have to see the output from this command everytime you start a new terminal session or refresh .bash_profile
.
[ ] Make sure you're correctly set-up by running
docker run hello-world
Either you'll get a print out from Docker saying hello, and some other things. If you've gotten an error it's time to debug. (If you need to debug try running boot2docker shellinit
and seeing if that fixes it. If not try running sudo docker run hello-world
. If neither of those work you're on your own, have fun!)
A running Docker container is based on an image, which you'll need to download onto your host machine. Downloading an image for the first time can take a few minutes depending on the size of the image, but once you have it, making modifications to it and running containers based on it is very fast. We are going to need 2 images, one for our web server and one for our Mongo database: pull
the from DockerHub with:
docker pull node:onbuild
and
docker pull mongo
Running docker images
should indicate you have both the node
and mongo
images.