通用指南 (docker commands in general)

docker build

Build a docker image from Dockfile. If no file name is specified, it will build from ./Dockerfile.

docker run

Run a docker container from an image. Most used options are:

docker inspect

Show low-level details of containers, specified by id or name.

docker attach

Attach to the container’s STDIN, STDOUT and STDERR. This is very useful to do trouble-shooting or monitoring when the container was launched in background mode, i.e. detached mode.

docker ps

Just like Linux ps command, this lists all running containers.

docker images

List all docker images available on this machine.

docker rename

Rename a docker container to a new name

docker rmi

Remove a docker image

docker compose commands

docker-compose up

Start up the services defined in the default configuration file, which is docker-compose.yml

docker-compose down

Stop all services which were brought up previous by a docker-compose up command. It will delete the containers after stop them. The docker network created will also be destroyed gracefully.

Other than docker-compose down, if you hit ctrl-c the containers will be stopped while not deleted. And the docker network will remain there. So it’s recommended to use this command to take the services down gracefully.

docker-compose exec

This is identical to docker exec. You can execute a command in a selected service.