Docker Commit提交

Docker Commit提交

Docker Commit镜像提交

  • 以一个正在运行的tomcat为例
  • 因为docker拉取的镜像都是删减版,所以需要将webapp.dist的文件内容复制到webapps中
  • 再将自己制作的镜像放在正在运行服务器上,不是云端服务器上
shell 复制代码
#进入tomcat,这是一个正在运行的tomcat
[root@iZf8zhsqf64x47n1tpdy6oZ ~]# docker exec -it a9e823629663 /bin/bash
root@a9e823629663:/usr/local/tomcat# ls
BUILDING.txt	 LICENSE  README.md	 RUNNING.txt  conf  logs	    temp     webapps.dist
CONTRIBUTING.md  NOTICE   RELEASE-NOTES  bin	      lib   native-jni-lib  webapps  work
root@a9e823629663:/usr/local/tomcat# cd webapps

#发现webapps内容为空
root@a9e823629663:/usr/local/tomcat/webapps# ls
root@a9e823629663:/usr/local/tomcat/webapps# cd ..

#复制webapps.dist全部内容至webapps
root@a9e823629663:/usr/local/tomcat# cp -r webapps.dist/* webapps

#复制完成后查看是否复制成功
root@a9e823629663:/usr/local/tomcat# cd webapps
root@a9e823629663:/usr/local/tomcat/webapps# ls
ROOT  docs  examples  host-manager  manager
#复制成功后退出
root@a9e823629663:/usr/local/tomcat/webapps# exit
exit
[root@iZf8zhsqf64x47n1tpdy6oZ ~]# cd /
[root@iZf8zhsqf64x47n1tpdy6oZ /]# docker ps
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS              PORTS                                        NAMES
a9e823629663        tomcat                "catalina.sh run"   17 minutes ago      Up 17 minutes       8080/tcp                                     elated_hypatia
af3bc99f4a47        portainer/portainer   "/portainer"        2 days ago          Up 41 hours         8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp   portainer

#提交自己修改的容器
[root@iZf8zhsqf64x47n1tpdy6oZ /]# docker commit -a="packet" -m="add webapp.dist to webapps" a9e823629663 tomcat01:1.0
sha256:0c109a855b95432460bccd95f2c13f96fe1128f40091e7903efbda6cc08d5252

#查看已经提交的容器
[root@iZf8zhsqf64x47n1tpdy6oZ /]# docker images -a
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
tomcat01                        1.0                 0c109a855b95        4 minutes ago       684 MB
docker.io/portainer/portainer   latest              5f11582196a4        15 months ago       287 MB
docker.io/nginx                 latest              605c77e624dd        2 years ago         141 MB
docker.io/tomcat                9.0                 b8e65a4d736d        2 years ago         680 MB
docker.io/tomcat                latest              fb5657adc892        2 years ago         680 MB
docker.io/mysql                 latest              3218b38490ce        2 years ago         516 MB
docker.io/centos                latest              5d0da3dc9764        2 years ago         231 MB
docker.io/elasticsearch         7.6.2               f29a1ee41030        3 years ago         791 MB

```shell
相关推荐
虎头金猫1 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
分布式存储与RustFS1 天前
MinIO 官方 Docker 镜像被移除:依赖它的项目该怎么办
docker·云原生·devops·对象存储·minio·分布式存储
AI职业加油站1 天前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
此冬歌咏1 天前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
玉&心1 天前
通过Arthas在线诊断K8S中的内存及JVM等使用情况
docker·k8s·arthas
xing-xing1 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
-梅1 天前
linux(8) 软硬链接
linux·运维·服务器
赵文宇(温玉)1 天前
CoreDNS的hosts插件的缺行配置导致k8s集群异常
容器·kubernetes·rancher
guo_wen_qiang1 天前
上传本地镜像到harbor中
docker·容器·持续部署
张洛闻Eren1 天前
k8s云原生【第十课】:水平 Pod 自动扩缩容
运维·数据库·云原生·kubernetes·github