root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# vi showpage.jsp
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# cat showpage.jsp
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test#
8.基于此制作新镜像
退出6a3c 容器,并停止容器
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# exit
exit
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" 2 hours ago Up 2 hours 0.0.0.0:8080->8080/tcp youthful_carson
[root@localhost ~]# docker stop 6a3c
6a3c
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" 2 hours ago Exited (143) 4 seconds ago youthful_carson
[root@localhost ~]#
使用以下命令,根据某个“容器 ID”来创建一个新的“镜像”:
docker commit 6a3c my_tomcat:1.0
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 9f38484d220f 11 days ago 202 MB
docker.io/tomcat 8 dd6ff929584a 2 weeks ago 463 MB
[root@localhost ~]#
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" 2 hours ago Exited (143) 2 minutes ago youthful_carson
[root@localhost ~]# docker commit 6a3c my_tomcat:1.0
sha256:20e7c603432c2d9b39598809a028cf9f4e30eb43bf3b5db287fb278d7cb43e11
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my_tomcat 1.0 20e7c603432c 14 seconds ago 510 MB
docker.io/centos latest 9f38484d220f 11 days ago 202 MB
docker.io/tomcat 8 dd6ff929584a 2 weeks ago 463 MB
[root@localhost ~]#
9.验证新镜像
docker run -d -p 8080:8080 my_tomcat