通用指南 (docker commands in general)
Build a docker image from Dockfile. If no file name is specified, it will build from
Run a docker container from an image. Most used options are:
- –interactive, -i Run the container in
- -t Run the container with a terminal (allocate a psudo-TTY)
- –name Name the container
- –env Set environment variables to the container. This is a very important way to differenciate running environment for containers. For example, in CloudOS, environment variables are defined in ADF files and then applied as environment variables to the containers.
Show low-level details of containers, specified by id or name.
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.
Just like Linux
ps command, this lists all running containers.
List all docker images available on this machine.
Rename a docker container to a new name
Remove a docker image
docker compose commands
Start up the services defined in the default configuration file, which is docker-compose.yml
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.
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.
This is identical to
docker exec. You can execute a command in a selected service.