1. docker commit 提交容器成为一个新的副本
    2. #命令与git相似
    3. docker commit -m="提交的描述信息" -a="作者" 容器id 目标镜像名:[TAG]

    实战:

    • 从Docker Hub仓库拉去tomcat9 版本 ```shell [root@wjh ~]# [root@wjh ~]# docker pull tomcat:9 9: Pulling from library/tomcat 376057ac6fa1: Pull complete 5a63a0a859d8: Pull complete 496548a8c952: Pull complete 2adae3950d4d: Pull complete 0a297eafb9ac: Pull complete 09a4142c5c9d: Pull complete 9e78d9befa39: Pull complete 18f492f90b9c: Pull complete 7834493ec6cd: Pull complete 216b2be21722: Pull complete Digest: sha256:ce753be7b61d86f877fe5065eb20c23491f783f283f25f6914ba769fee57886b Status: Downloaded newer image for tomcat:9 docker.io/library/tomcat:9 [root@wjh ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql 5.7 a4fdfd462add 2 days ago 448MB mysql latest 30f937e841c8 2 days ago 541MB tomcat 9 1b6b1fe7261e 6 days ago 647MB portainer/portainer latest 2869fc110bf7 2 months ago 78.6MB centos latest 470671670cac 4 months ago 237MB hello-world latest bf756fb1ae65 4 months ago 13.3kB
    1. - 启动tomcat
    2. ```shell
    3. [root@wjh ~]# docker run -it -p 8080:8080 tomcat:9
    • 启动成功后发现,默认的tomcat的webapps是没有文件的。此时,将webapps.dist中的文件拷贝进去
    • 将我们操作后的容器提交为一个新的镜像,保存到本地镜像库中
      1. [root@wjh ~]# docker commit -a="wjh" -m="add webapps files" b033769d0c8b tomcat02:1.0