概述
docker 镜像的删除
镜像删除 : 1.先查出所有的容器2.停止运行的容器3.删除要删除的镜像 根据镜像ID删除
列出所有运行的ID
docker ps
列出所有的容器的id
docker ps -a -q
docker 容器删除
删除正在运行的容器
docker rm -f 容器的id
删除未运行的容器
docker rm 容器的id
停止容器
docker stop 停止容器ID
启动容器
docker start
重启容器
docker restart
1.先停止运行的容器
docker ps 列出所有运行的容器
docker ps -a -q 显示所有容器包括未运行的 -q静默模式 只显示容器编号
docker stop $(docker ps -a -q) 停止所有的container
docker rm $(docker ps -a -q) 删除所有的container
docker images 查看有哪些镜像
想要删除未标记的 images,也就是那些id为的image的话可以用
docker rmi $(docker images | grep “^” | awk “{print $3}”)
要删除全部image的话
docker rmi $(docker images -q)
2.再删除镜像
docker rmi -f 4ab4c602aa5e#镜像的ID
1.docker容器删除
列出正在运行的容器
docker ps -a 是列出所有的容器 包括未运行的
[root@iz0g3gpu4amylwz /]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3684561d2e3d redis:3.2 “docker-entrypoint.s…” 2 minutes ago Up 2 minutes 6379/tcp, 0.0.0.0:6379->63791/tcp adoring_heyrovsky
fa05e0515c49 redis:3.2 “docker-entrypoint.s…” 6 minutes ago Created hardcore_hoover
77ed92a982de redis:3.2 “docker-entrypoint.s…” 7 minutes ago Created practical_mcnulty
be42f394f206 4ab4c602aa5e “/hello” About an hour ago Exited (0) About an hour ago frosty_benz
9b0f6b466da9 4ab4c602aa5e “/hello” 5 weeks ago Exited (0) 5 weeks ago hungry_borg
3ddc87805976 4ab4c602aa5e “/hello” 5 weeks ago Exited (0) 5 weeks ago reverent_haibt
d37b9e96a5ae redis:3.2 “docker-entrypoint.s…” 5 weeks ago Exited (0) 5 weeks ago wpredis
列出运行的容器只显示 containerID容器id
[root@iz0g3gpu4amylwz /]# docker ps -q
3684561d2e3d
停止正在运行的容器
docker stop (容器的ID ===containerID) 停止
docker start (容器的ID ====containerID) 运行
docker restart(容器的ID ====containerID) 重启
[root@iz0g3gpu4amylwz /]# docker stop 3684561d2e3d
3684561d2e3d
[root@iz0g3gpu4amylwz /]# docker ps -q
[root@iz0g3gpu4amylwz /]#
删除容器
docker rm 容器的ID(containerID)
docker rm -f 强制删除正在运行的容器
[root@iz0g3gpu4amylwz /]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3684561d2e3d redis:3.2 “docker-entrypoint.s…” 19 minutes ago Exited (0) 13 minutes ago adoring_heyrovsky
fa05e0515c49 redis:3.2 “docker-entrypoint.s…” 23 minutes ago Created hardcore_hoover
77ed92a982de redis:3.2 “docker-entrypoint.s…” 24 minutes ago Created practical_mcnulty
9b0f6b466da9 4ab4c602aa5e “/hello” 5 weeks ago Exited (0) 5 weeks ago hungry_borg
3ddc87805976 4ab4c602aa5e “/hello” 5 weeks ago Exited (0) 5 weeks ago reverent_haibt
d37b9e96a5ae redis:3.2 “docker-entrypoint.s…” 5 weeks ago Exited (0) 5 weeks ago wpredis
[root@iz0g3gpu4amylwz /]# docker ps -a -q
3684561d2e3d
fa05e0515c49
77ed92a982de
9b0f6b466da9
3ddc87805976
d37b9e96a5ae
[root@iz0g3gpu4amylwz /]# docker rm 3ddc87805976
3ddc87805976
[root@iz0g3gpu4amylwz /]# docker ps -a -q
3684561d2e3d
fa05e0515c49
77ed92a982de
9b0f6b466da9
d37b9e96a5ae
[root@iz0g3gpu4amylwz /]#
2.删除镜像
删除镜像
docker rmi -f 镜像ID
-f 是强制删除镜像 删除镜像后 所创建的容器也一并删除
[root@iz0g3gpu4amylwz /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 1babb1dde7e1 2 weeks ago 94.9MB
redis 3.2 2fef532eadb3 2 months ago 76MB
[root@iz0g3gpu4amylwz /]# docker rmi -f 2fef532eadb3
Untagged: redis:3.2
Untagged: redis@sha256:745bdd82bad441a666ee4c23adb7a4c8fac4b564a1c7ac4454aa81e91057d977
Deleted: sha256:2fef532eadb328740479f93b4a1b7595d412b9105ca8face42d3245485c39ddc
[root@iz0g3gpu4amylwz /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 1babb1dde7e1 2 weeks ago 94.9MB
[root@iz0g3gpu4amylwz /]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3684561d2e3d 2fef532eadb3 “docker-entrypoint.s…” 21 minutes ago Exited (0) 15 minutes ago adoring_heyrovsky
fa05e0515c49 2fef532eadb3 “docker-entrypoint.s…” 25 minutes ago Created hardcore_hoover
77ed92a982de 2fef532eadb3 “docker-entrypoint.s…” 26 minutes ago Created practical_mcnulty
9b0f6b466da9 4ab4c602aa5e “/hello” 5 weeks ago Exited (0) 5 weeks ago hungry_borg
d37b9e96a5ae 2fef532eadb3 “docker-entrypoint.s…” 5 weeks ago Exited (0) 5 weeks ago wpredis
[root@iz0g3gpu4amylwz /]#
最后
以上就是要减肥蚂蚁为你收集整理的centos7 docker 容器的创建/删除/运行 镜像 安装/删除的全部内容,希望文章能够帮你解决centos7 docker 容器的创建/删除/运行 镜像 安装/删除所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复