1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| docker commit 提交容器成为一个新的副本
docker commit -m="提交的描述信息" -a="作者" 容器id 自定义镜像名:[自定义版本信息]
1.启动一个默认的tomcat 2.发现这个是默认的tomcat webapps目录下没有文件,我们要去webapps.dist目录下去拷贝到webapps下或者直接改名webapps.dist文件 3.将我们操作过的容器提交成一个镜像!我们以后就是就使用我们修改过的镜像即可
root@again:~ sha256:816c97ffd0ad3d32687f735c341a25dc00dd80d911b9df97f32150d29e37e400 root@again:~ REPOSITORY TAG IMAGE ID CREATED SIZE **tomcat 1.0 816c97ffd0ad 4 seconds ago 653MB** tomcat 9.0 625b734f984e 3 days ago 648MB tomcat latest 625b734f984e 3 days ago 648MB nginx latest f35646e83998 13 days ago 133MB elasticsearch 7.6.2 f29a1ee41030 7 months ago 791MB
|
commit完成发布自己的镜像
发布自己的镜像到DockerHub
- 在官网 https://hub.docker.com/ 上注册自己的账号
- 确保账号可以登录
- 在我们的服务器上提交自己的镜像
1 2 3 4 5 6 7 8 9 10 11 12
| [root@mylinux ~]
Usage: docker login [OPTIONS] [SERVER]
Log in to a Docker registry. If no server is specified, the default is defined by the daemon.
Options: -p, --password string Password --password-stdin Take the password from stdin -u, --username string Username
|
提交到自己的仓库需要注意
**提交的时候镜像命令要是你的dockerhub名称加上镜像名加上:TAG标记,这样就可以提交成功了(意思就是你的镜像名称必须为你的dockerhub名称加上你的镜像名和版本号)
例如你的dockerHub用户名为 hello
你提交的镜像名称必须为 hello/镜像名:tag**
[root@mylinux ~]# docker push sky0429/mytomcat:1.0
The push refers to repository [docker.io/sky0429/mytomcat]
12ce4d49a2bf: Pushed
b1f6ac31789f: Pushed
a0ff47fa59d6: Pushed
291f6e44771a: Pushed
1.0: digest: sha256:047b039ac9326c10471ec6ce530c453efdea5925e12b02ce921c01a34e6b0ae9 size: 1166