基于容器制作镜像

基于容器制作镜像
对容器进行更改从而创建一个新镜像
用法:

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Options Default Description
—author, -a Author (e.g., "John Hannibal Smith hannibal@a-team.com")
-c, --change list 对创建的镜像应用 Dockerfile 指令
-m, --message string 提交消息
-p, --pause ture 在提交期间暂停容器

[root@localhost ~]# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
Digest: sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678
Status: Image is up to date for busybox:latest
docker.io/library/busybox:latest
[root@localhost ~]# 
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
busybox      latest    beae173ccac6   3 months ago   1.24MB
httpd        latest    dabbfbe0c57b   4 months ago   144MB
[root@localhost ~]# docker run -it --name b1 busybox
/ # mkdir data
/ # echo 'hello world' > data/index.html
/ # cat /data/index.html 
hello world
[root@localhost ~]# docker commit -p b1
sha256:121711e0cdc98ac8573dd7ab953ce66dc6905a787a3965b1e82c5fabf9b23b3e
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
<none>       <none>    121711e0cdc9   15 seconds ago   1.24MB
busybox      latest    beae173ccac6   3 months ago     1.24MB
httpd        latest    dabbfbe0c57b   4 months ago     144MB
[root@localhost ~]# docker tag  121711e0cdc9 busybox:v0.1
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
busybox      v0.1      121711e0cdc9   6 minutes ago   1.24MB
busybox      latest    beae173ccac6   3 months ago    1.24MB
httpd        latest    dabbfbe0c57b   4 months ago    144MB
[root@localhost ~]# docker tag 121711e0cdc9 xwsxkx/b1:v0.1
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
busybox      v0.1      121711e0cdc9   37 minutes ago   1.24MB
xwsxkx/b1    v0.1      121711e0cdc9   37 minutes ago   1.24MB
busybox      latest    beae173ccac6   3 months ago     1.24MB
httpd        latest    dabbfbe0c57b   4 months ago     144MB

此时要注意的是,我们的仓库名叫b1,所以我们要在Docker Hub上创建一个名为b1的仓库,然后再将我们做好的镜像push上去

[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
busybox      v0.1      121711e0cdc9   37 minutes ago   1.24MB
xwsxkx/b1    v0.1      121711e0cdc9   37 minutes ago  
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值