Docker续1:docker使用

一、打包传输

1.打包

[root@localhost ~]# systemctl start docker
[root@localhost ~]# docker save -o centos.tar centos:latest 
[root@localhost ~]# ls
anaconda-ks.cfg  centos.tar

2.传输

[root@localhost ~]# scp centos.tar root@192.168.1.100:/root

3.删除镜像

[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
centos       latest    5d0da3dc9764   2 years ago   231MB
[root@localhost ~]# docker start c0                   //启动容器
c0
[root@localhost ~]# docker attach c0                     //进入容器
[root@207ca7680ecc /]# exit
exit
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@localhost ~]# docker ps --all                         //查看全部
CONTAINER ID   IMAGE           COMMAND       CREATED        STATUS                     PORTS     NAMES
207ca7680ecc   centos:latest   "/bin/bash"   20 hours ago   Exited (0) 4 seconds ago             c0
[root@localhost ~]# docker rmi centos:latest                               //这里看到没有删掉,因为有容器正在使用
Error response from daemon: conflict: unable to remove repository reference "centos:latest" (must force) - container 207ca7680ecc is using its referenced image 5d0da3dc9764
[root@localhost ~]# docker rm c0                                  //删除容器
c0
[root@localhost ~]# docker ps --all
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@localhost ~]# docker rmi centos:latest                                   //成功删除
Untagged: centos:latest
Untagged: centos@sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Deleted: sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c52c45d4847e53fadb6
Deleted: sha256:74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59
[root@local

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值