快捷菜单
常用功能一站直达
更多功能请点顶栏「快捷菜单」
不推荐)-2022.2.281docker commit 容器id 镜像name:tag 1step1:运行一个centos容器
2[root@xyy admin]###docker run -it -d centos
3608078af64734e4a199b75ce337959e22c2944464a4a9f723fcc3ad2e8d42d85
4[root@xyy admin]###docker ps
5CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6608078af6473 centos "/bin/bash" 3 seconds ago Up 2 seconds boring_meninsky
7
8step2:进到这个centos容器里面,构建好我们需要的环境
9[root@xyy admin]###docker exec -it 608078af6473 bash
10[root@608078af6473 /]### yum install nginx
11Failed to set locale, defaulting to C.UTF-8
12CentOS Linux 8 - AppStream 2.3 MB/s | 8.1 MB 00:03
13CentOS Linux 8 - BaseOS 5.8 MB/s | 3.5 MB 00:00
14^CCentOS Linux 8 - Extras 1.9 kB/s | 6.6 kB 00:03
15Error: Failed to download metadata for repo 'extras': Librepo was interrupted by a signal
16[root@608078af6473 /]### exit
17exit
18
19step3:使用commit命令将容器转换成我们需要的镜像
20###先来查看下当前本地镜像信息
21[root@xyy admin]###docker images
22REPOSITORY TAG IMAGE ID CREATED SIZE
23centos latest 5d0da3dc9764 2 months ago 231MB
24
25###开始构建镜像
26[root@xyy admin]###docker commit 608078af6473 test-commit-command:v1
27sha256:8fa14905fbf663736f24188e2d2a1a1ca08621c2672b7e64ac7c58adf46b66ac
28
29step4:构建完成后我们验证下
30[root@xyy admin]###docker images
31REPOSITORY TAG IMAGE ID CREATED SIZE
32test-commit-command v1 8fa14905fbf6 9 seconds ago 257MB
33centos latest 5d0da3dc9764 2 months ago 231MB
34[root@xyy admin]###docker commit我的博客主旨:
🍀 微信二维码 x2675263825 (舍得), qq:2675263825。

🍀 微信公众号 《云原生架构师实战》

🍀 个人博客站点
http://47.97.48.237/ (即将上线域名:onedayxyy.cn)

🍀 语雀
https://www.yuque.com/xyy-onlyone

🍀 csdn https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

🍀 知乎 https://www.zhihu.com/people/foryouone

好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!
日历 · 精选 · 友链 · 更多
如果内容对你有帮助,欢迎请我喝杯咖啡 ☕



One的公众号
爱折腾博客的小白