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 192.168.59.103 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 192.168.99.100 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        0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcp   web
$ docker-machine ip dev
192.168.99.100