实例演示:
[root@docker ~]# docker import centos_contain centos_new:54 sha256:f32b5354c81de72a71af50468d09803aa9e62e08741e3cd3e84c10c9a74e2204 [root@docker ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos_new 54 f32b5354c81d 10 seconds ago 0B nginx latest ed21b7a8aee9 6 days ago 127MB centos latest 470671670cac 2 months ago 237MB可能利用cat 文件名 | docker import - 镜像名称:tag 执行呼吁也可以的
5、容器的删除容器的删除:docker rm
呼吁名目:docker rm [OPTIONS] CONTAINER [CONTAINER...]
实例演示:
[root@docker ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4835176a7d8e centos "/usr/bin/bash -c ls…" 31 minutes ago Exited (0) 31 minutes ago affectionate_keldysh a1a2e8468189 nginx:latest "/bin/bash" 58 minutes ago Up 19 minutes 80/tcp gallant_feynman删除已终止的容器:
[root@docker ~]# docker rm 4835176a7d8e 4835176a7d8e [root@docker ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a1a2e8468189 nginx:latest "/bin/bash" 59 minutes ago Up 20 minutes 80/tcp gallant_feynman删除乐成了!
删除还在运行中的容器:
[root@docker ~]# docker rm a1a2e8468189 Error response from daemon: You cannot remove a running container a1a2e8468189b146b0215971cf76947987d8fc3f42c58e77371e8d48afb030d1. Stop the container before attempting removal or force remove发明Error了,不能这样删除运行状态中的容器,提示你的操纵是实验删除容器前遏制容器的运行可能强制删除
推荐前者,后者只需要如下操纵,但只管不要随意利用哈!
[root@docker ~]# docker rm a1a2e8468189 -f a1a2e8468189 [root@docker ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES友情提示:docker默认的存储目次在/var/lib/docker目次下,docker的镜像、容器、日志等内容全部都存储在此,虽然也可以单独利用大容量的分区来存储这些内容,而且一般选择成立在LVM逻辑卷,从而利便后续扩容操纵。
总结 本文报告的是docker基本呼吁(镜像和容器)的操纵,通过实实在在的实际案例利便领略。对付docker的先容与安装可以查阅笔者的前一篇文章。
感激阅读!
Linux公社的RSS地点:https://www.linuxidc.com/rssFeed.aspx