Install Docker on Mac OS X

Feb 28, 2016 Docker 中文版

Docker is a powerful and easy-to-use product that helps developers to build and deploy applications. This article is about how to install and use Docker on Mac OS X.



Install Docker

On Mac, we can install Docker via Homebrew, and I think it’s the simplest way. In fact, we’re going to install Dockertoolbox, which includes many tools that we will use in the future. Of course, you can manually install each of them via Homebrew. To install Dockertoolbox:

# Search Dockertoolbox
brew search dockertoolbox

# Install Dockertoolbox
brew install Caskroom/cask/dockertoolbox


Use Docker Machine

Docker Machine is a tool that allows us to create an environment for Docker. If you’re using Mac or Windows, you have to use Docker Machine. To create an environment for Docker:

# Create a env named myDocker with virtualbox driver
docker-machine create -d virtualbox myDocker

After created the env, let’s get the information about myDocker:

docker-machine env myDocker

There’s a command in the information:

# Run this command to configure your shell:
# eval (docker-machine env myDocker)

Execute eval (docker-machine env myDocker), and then you use docker commands in the terminal. Here are some useful commands:

# List all machines
docker-machine ls

# Start a machine
docker-machine start <your-machine-name>

# Stop a machine
docker-machine stop <your-machine-name>

# Remove a machine
docker-machine rm <your-machine-name>


Docker Useful Commands

Here are Docker useful commands:

# Get system-wide information
docker info

# List all images
docker images

# Remove a image
docker rmi <IMAGE-ID>

# Run a CentOS6 container, and it will automatically download if you don't have such image
docker run centos:centos6

# Run a CentOS5 container
docker run centos:centos5

# Manually get the latest CentOS image
docker pull centos:latest

# List containers
# 1) Option: -a  list all containers (stopped and running)
# 2) Option: -l  list the latest container
docker ps




You might also like:




If you have any suggestions, questions or even find some typos, feel free to contact me. Thank you! :)

zeckli.devforgalaxy@gmail.com   © 2015-2019 zeckli, thanks to Jekyll and GitHub.