Docker常用命令

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}')

posted on 2019-03-08 11:08  Ruthless  阅读(7925)  评论(0编辑  收藏  举报