avatar

目錄
Docker command 常用指令

Image

bash
docker images -a      # list all docker images
docker rmi [image id] # remove image
docker pull [image] # pull an image or a repository from a registry

Container

bash
docker ps     # show all running containers
docker ps -a # show all containers (including the running and stopped containers)

docker start [container id]
docker stop [container id] # stop the container, still there when docker ps -a
docker restart [container id]

docker rm [container id] # remove container, no longer contain when docker ps -a. rm cannot remove a running container unless with -f
bash
docker run
# It is the combination of the following 3 commands:
# 1. docker container create
# 2. docker container start
# 3. docker container attach
bash
docker system prune
# This will remove:
#- all stopped containers
#- all networks not used by at least one container
#- all dangling images
#- all dangling build cache

Docker compose

docker compose up

Create and start all containers within docker-compose.yml

bash
docker compose up

docker compose down

Stop all containers and remove networks relating to docker-compose.yml. It will NOT delete any volume unless the -v option is used.

bash
docker compose down
docker compose down -v

References


如果您喜歡我的文章,歡迎幫我在下面按5下讚!感謝您的鼓勵和支持!

文章作者: ouoholly
文章鏈接: https://ouoholly.github.io/post/docker-command-notes/
版權聲明: 本博客所有文章除特別聲明外,均採用 CC BY-NC-SA 4.0 許可協議。歡迎「部份引用」與介紹(如要全文轉貼請先留言詢問),轉載引用請註明來源 ouoholly 的倉庫,謝謝!

評論