docker 列出所有容器ID
docker ps -aq
[root@localhost conf]# docker ps -aq
f81aa5f48427
06a66409d7ce
1c3d38b948ba
62233dfad35b
4b0032878886
0f6f368c4c1d
7d98a59a8012
1906ba6bfbe1
[root@localhost conf]#
docker 查看所有运行容器
docker ps -a
[root@localhost conf]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f81aa5f48427 mysql:8.0.23 "docker-entrypoint.s…" 30 hours ago Up 21 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
06a66409d7ce wurstmeister/kafka "start-kafka.sh" 6 months ago Exited (255) 4 months ago 0.0.0.0:9092->9092/tcp kafka
1c3d38b948ba zookeeper "/docker-entrypoint.…" 6 months ago Up 2 hours 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp zookeeper
62233dfad35b minio/minio "/usr/bin/docker-ent…" 6 months ago Up 2 hours minio-server
4b0032878886 6c3c2a225947 "docker-entrypoint.s…" 6 months ago Exited (255) 4 months ago 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rabbitmq
0f6f368c4c1d elasticsearch:7.6.2 "/usr/local/bin/dock…" 8 months ago Exited (143) 6 months ago elasticsearch
7d98a59a8012 mysql:5.7 "docker-entrypoint.s…" 8 months ago Exited (0) 8 months ago mysql-slave
1906ba6bfbe1 mysql:5.7 "docker-entrypoint.s…" 8 months ago Exited (137) 8 months ago mysql-master
docker 查看正在运行容器
docker ps
[root@localhost conf]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f81aa5f48427 mysql:8.0.23 "docker-entrypoint.s…" 30 hours ago Up 20 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
1c3d38b948ba zookeeper "/docker-entrypoint.…" 6 months ago Up 2 hours 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp zookeeper
62233dfad35b minio/minio "/usr/bin/docker-ent…" 6 months ago Up 2 hours minio-server
docker 停止指定的container(容器)
docker stop containerId
温馨提示:删除container(容器)的镜像文件,必须先停止container(容器)运行。
知识拓展:停止docker 所有容器(包含正在运行)container(容器)
docker stop $(docker ps -a -q) 或者 docker stop $(docker ps -aq)
docker 删除指定的container(容器)
ocker rm containerId
知识拓展:想要删除所有container(容器),执行如下指令:
docker rm $(docker ps -a -q) 或者 docker rm $(docker ps -aq)
docker 查看包含images(镜像)
docker images
[root@localhost conf]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 0e901e68141f 9 months ago 142MB
mysql 5.7 2a0961b7de03 9 months ago 462MB
minio/minio latest e31e0721a96b 13 months ago 406MB
wurstmeister/kafka latest 2dd91ce2efe1 13 months ago 508MB
zookeeper latest 36c607e7b14d 14 months ago 278MB
rabbitmq management 6c3c2a225947 14 months ago 253MB
mysql 8.0.23 cbe8815cbea8 22 months ago 546MB
elasticsearch 7.6.2 f29a1ee41030 2 years ago 791MB
delron/fastdfs latest 8487e86fc6ee 4 years ago 464MB
Docker 删除images(镜像)
docker rmi <image id>
Docker 删除全部image(镜像)
docker rmi $(docker images -q)
Docker 强制删除全部image(镜像)
docker rmi -f $(docker images -q)
Docker 停止所有容器
docker container prune
Docker 删除所有不使用的镜像
docker image prune --force --all或者docker image prune -f -a
Docker 停止、启动、杀死、重启容器
docker stop containerName或者containerID
docker start containerName或者containerID
docker kill containerName或者containerID
docker restart containername或者containerID
Docker进入指定容器,查看/修改相关配置文件文章来源:https://www.toymoban.com/news/detail-436811.html
docker exec :在运行的容器中执行命令
-d :分离模式: 在后台运行
-i :即使没有附加也保持STDIN(标准输入) 打开,以交互模式运行容器,通常与 -t 同时使用;
-t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
docker exec -it mysql /bin/bash
修改配置、退出容器文章来源地址https://www.toymoban.com/news/detail-436811.html
1、如果要正常退出不关闭容器,请按Ctrl+P+Q进行退出容器
2、如果使用exit退出,那么在退出之后会关闭容器,可以使用下面的流程进行恢复
使用docker restart命令重启容器
使用docker attach命令进入容器
到了这里,关于Docker 查询、停止、删除和重启容器的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!