1、查看已有的鏡像
# docker images
2、運行xinyar/erp-web鏡像
# docker run -d --restart=always -p 8091:8091 --name xinyar_erp_web_test xinyar/erp-web
參數說明:
-d 開啟Daemon模式
--restart=always在容器退出時總是重啟容器(docker開機/重啟)
-p 8091:8091 指定端口映射,eg:
-p hostPort:containerPort
-p ip:hostPort:containerPort
-p ip::containerPort
-p hostPort:containerPort:udp
--name xinyar_erp_web_test 容器識別
xinyar/erp-web 指定鏡像名稱
3、動態查看容器日志
# docker logs containerName/containerId
eg、
docker logs -f xinyar_erp_web_test
docker logs -f 0f9b05aa74cf
4、關閉容器
# docker stop containerName/containerId
eg、
docker stop xinyar_erp_web_test
5、啟動容器
# docker start containerName/containerId
eg、
docker start xinyar_erp_web_test
6、重啟容器
# docker restart containerName/containerId
eg、
docker restart xinyar_erp_web_test
7、刪除容器
# docker rm –f containerName/containerId
eg、
docker rm -f xinyar_erp_web_test
8、刪除鏡像
# docker rmi -f IMAGE_ID/ REPOSITORY:TAG
eg、docker rmi -f f104cf54406b
docker rmi -f registry: latest
若TAG為latest,則可不用寫,如: docker rmi -f registry
9、查看鏡像列表
# docker search images_name
10、從公網拉取一個鏡像
# docker pull images_name
11、查看幫助
# docker command --help
12、看容器的端口映射情況
# docker port con_id
eg、docker port 51d58caec77d
13、查看正在運行的容器
# docker ps
14、查看所有的容器
# docker ps -a
15、進入容器
# docker exec -it 容器ID /bin/bash
# docker attach containerId #不推薦使用(退出容器的時候,容器會停止)
16、查看docker網絡
# docker network ls
17、查看容器pid
# docker top con_name
eg、docker top xinyar_erp_web_test
18、強制刪除鏡像名稱中包含“doss-api”的鏡像
docker rmi --force $(docker images | grep doss-api | awk '{print $3}')