Table of Contents

  1. Install
  2. Uninstall
    1. Uninstall from GUI
    2. Uninstall from command
  3. Command
    1. Docker run
    2. Others
  4. Dockerfile
  5. Container Link

Docker is the world’s leading software containerization platform
Docker Official Site
Docker Hub: search images from this site

Install

Go to Official Site and click download.

Uninstall

Uninstall from GUI

Choose –> Preferences from the menu bar, then click Uninstall / Reset on the Preferences dialog.

Uninstall from command

1
2
3
$ /Applications/Docker.app/Contents/MacOS/Docker --uninstall
Docker is running, exiting...
Docker uninstalled successfully. You can move the Docker application to the trash.

Command

Docker run

  • -d #run in background(demen)
  • -p 80:5000 #map host 80 port to container 5000 port
  • -t -i #execute interactive terminal
  • –name
1
2
3
4
docker run <userID>/<imageName> <command> <command parameter>
docker run -d -p 80:5000 training/webapp python app.py # -p 80:5000 to map container 5000 port to host 80 post, -d to run in background
docker run -t -i ubuntu:14.04 /bin/bash # run interactive bash
docker run -d -P --name web training/webapp python app.py # give container a name

Others

1
2
3
4
5
6
7
8
9
10
11
12
13
14
docker pull <image> # pull image
docker inspect <container ID> # see the container specific info
docker ps # list current running container
docker ps -a # list all container
docker stop <container name> # stop container
docker rm -f <container name>|<container id> # remove container
docker images # list all images
docker rmi <imageID>|<imageName> # remove image
docker build -t <userID>/<imageName> ./ # build image according to Dockfile
docker tag <imageID> <userID>/<imageName>:latest
docker logs -f <container ID> # print stdout of container
docker login
docker push <userID>/<imageName>

Dockerfile

1
2
3
4
5
# an easy example
FROM docker/whalesay:latest # use other image as base
RUN apt-get -y update && apt-get install -y fortunes # run init command
ENV POSTGRES_USER faceblock
CMD /usr/games/fortune -a | cowsay

Container Link

1
2
docker run -d --name db training/postgres # creates a container called db, which contains a PostgreSQL database.
docker run -d -P --name web --link db:db training/webapp python app.py # create a web container and link it with db container