提示:以下是本篇文章正文内容,下面案例可供参考
发布镜像到docker hub
前提
注册账号
docker hub 官网地址 https://hub.docker.com
注客户端配置daemon.json
检查registry-mirrors 和insecure-registries节点为缺省值,也就是[]
默认没有设置过的就是缺省值
执行登录
[root@localhost ~]# docker login
构建好自己的容器
比如spingboot-docker
打包镜像
分为两种:
1.通过tag 方式打包镜像
语法docker tag imageName:version userName/imageName:version
[root@localhost ~]# docker tag springboot-docker:latest andy1986/springboot-docker:latest
2.通过commit方式打包镜像
[root@localhost ~]# docker -d --name springboot-docker -p 8080:8080 springboot-docker
#此时通过docker ps -l 会得到一个容器id sdfs5203sdfs1
重新打包镜像
docker commit <容器名> <镜像名>
[root@localhost ~]# docker commit sdfs5203sdfs1 andy1986/springboot-docker
镜像命名规则
比如andy1986/springboot-docker的镜像
语法userName/imageName
andy1986是我的docker hub 用户名 /前面要符是你的用户名,才符合hub的规范
最后执行push
[root@localhost ~]# docker push andy1986/springboot-docker
Using default tag: latest
The push refers to repository [docker.io/andy1986/springboot-docker]
586dea2aa03a: Pushed
35c20f26d188: Mounted from library/java
c3fe59dd9556: Mounted from library/java
6ed1a81ba5b6: Mounted from library/java
a3483ce177ce: Mounted from library/java
ce6c8756685b: Pushed
30339f20ced0: Mounted from library/java
0eb22bfb707d: Mounted from library/java
a2ae92ffcd29: Mounted from library/java
latest: digest: sha256:821126226c6229b8b2a463498e7586dd0d4b49a26dcf26dea9e5d1a4640cd9fa size: 2212
拉取镜像
[root@localhost ~]# docker pull andy1986/springboot-docker
阿里云dockerHub
阿里云dockerhub 仓库
https://cr.console.aliyun.com/cn-hangzhou/instances/repositories
麻烦各位点个赞,支持支持下,祝大家心想事成,谢谢~