在名为guest的容器内运行bash shell:
[root@host ~]
[root@guest ~]
如果你使用网络代理,按照《Oracle Linux 7版本管理员指南》中的说明在虚拟机上编辑yum配置。
安装httpd软件包:
[root@guest ~]
如果需要,在客户端上创建要显示在/var/www/html
目录层次结构下的Web内容。
使用主机上的docker stop命令退出客户端:
[root@host ~]
guest
使用您停止的容器的ID创建标签为
v1
的镜像
mymod/httpd
:
[root@host ~]# docker commit -m "ol6 + httpd" -a "A N Other" \
`docker ps -l -q` mymod/httpd:v1
8594abec905e6374db51bed1bfb208804cfb60d96b285efb897db581a01676e9
使用
-m
和
-a
选项来记录镜像及其作者。该命令将返回新镜像ID的完整版本。
如果使用docker images命令,则新镜像现在会出现在列表中:
[root@host ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
mymod/httpd v1 8594abec905e 2 minutes ago 938.5 MB
oraclelinux 6 9ac13076d2b5 5 days ago 319.4 MB
oraclelinux 6.6 9ac13076d2b5 5 days ago 319.4 MB
oraclelinux latest 073ded22ac0f 5 days ago 265.2 MB
oraclelinux 7 073ded22ac0f 5 days ago 265.2 MB
oraclelinux 7.0 073ded22ac0f 5 days ago 265.2 MB
删除名为guest的容器。
guest
现在您可以使用新的镜像创建一个作为Web服务器工作的容器,例如:
7afbbefec5191f632e149f85ae10ed0ba88f1c545daad18cb930e575ef6a3e63
kubectl
具有此功能非常有帮助。 - imriss