docker:修改镜像内容

## 1.查看image

[root@VM_0_9_centos ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

anaconda3 v2 69fbd3d374ef 6 days ago 2.74 GB

anaconda3 v1 5f7b8a1f9a53 7 days ago 2.74 GB

docker.io/continuumio/anaconda3 latest bdb4a7e92a49 9 days ago 2.7 GB

docker.io/centos latest 470671670cac 2 months ago 237 MB

docker.io/centos 7 5e35e350aded 4 months ago 203 MB

## 2. 启动容器

[root@VM_0_9_centos ~]# docker run -dit --name centos7 docker.io/centos:7

f03ad3e5b9853b06160fc9d602063c6adc27172f186f516b7ea2000cb9db1f54

[root@VM_0_9_centos ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

f03ad3e5b985 docker.io/centos:7 "/bin/bash" 16 seconds ago Up 16 seconds centos7

## 3. 进入容器后,做一些修改

[root@VM_0_9_centos ~]# docker exec -it centos7 bash

## 4. 将容器centos7保存为centos:latest镜像

[root@VM_0_9_centos ~]# docker commit -a 'kwq' -m 'make some change' centos7 centos7:latest

sha256:952de7d78abf1ef54206c18ea86f62998bf749724fd65655f5cc278106c9e894

[root@VM_0_9_centos ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

centos7 latest 952de7d78abf 4 seconds ago 203 MB

anaconda3 v2 69fbd3d374ef 7 days ago 2.74 GB

anaconda3 v1 5f7b8a1f9a53 7 days ago 2.74 GB

docker.io/continuumio/anaconda3 latest bdb4a7e92a49 9 days ago 2.7 GB

docker.io/centos latest 470671670cac 2 months ago 237 MB

docker.io/centos 7 5e35e350aded 4 months ago 203 MB

## 5. 将原centos7的容器停止、删除

[root@VM_0_9_centos ~]# docker stop centos7

centos7

[root@VM_0_9_centos ~]# docker rm centos7

centos7

## 6. 启动centos7:latest镜像

[root@VM_0_9_centos ~]# docker run -dit --name centos7 centos7:latest

53e1009d63027a25291c5b9a5cc84332cb4ac7012f5cd221ccb9a83d81333c67

## 7. 查看容器中的更改是否丢失

[root@VM_0_9_centos ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

53e1009d6302 centos7:latest "/bin/bash" 7 seconds ago Up 6 seconds centos7

[root@VM_0_9_centos ~]# docker exec -it centos7 bash

## 8. 保存镜像为tar包

[root@VM_0_9_centos ~]# docker save -o centos7.tar docker.io/centos:latest

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kangwq2017

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值