My Avatar

Shilong ZHAO

Docker on Mac OS

2015-11-23 00:00:00 +0100

In case you have any questions or suggestions, you can leave comments HERE . Thanks!

On Mac or Windows, it lacks the native running environment for containers, thus a virtual machine is needed.

A virtual machine named boot2docker-vm will hold docker daemon and containers if boot2docker is used. IP will be used for the virtual machine.

In newer distributions, an alternative program name docker-machine do the same task as boot2docker.

if you are using docker-machine, VM default is used to run daemon, ip will be used.

Docker clients (docker command on terminal) communicate with docker containers through ports, there will be a port mapping between the VM and the containers.

Docker images are stored in the virtual machines (hosts), if there is no such images, it will be downloaded. If you use a new VM as host, the images will be re-downloaded to it.

docker-machine create --driver virtualbox dev
$ docker-machine start dev
$ eval "$(docker-machine env dev)"
$ docker run -d -P --name web nginx
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                           NAMES
a1ff2361e090        nginx               "nginx -g 'daemon off"   11 hours ago        Up 3 minutes>80/tcp,>443/tcp   web
$ docker-machine ip dev