一、发布镜像到DcokerHub
- 首先需要去https://hub.docker.com/网站注册属于自己的账号;
- 确定新注册的账号可以登陆;
- 在我们的服务器上提交自己制作的镜像文件。
[[email protected] ~]# docker login --help
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
[[email protected] ~]# docker login -u jzyue
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[[email protected] ~]# docker push jzyue/tomcat01:1.0 #提交自己的镜像到dockerhub上
The push refers to repository [docker.io/jzyue/tomcat01]
cd2c8c332d4e: Pushing [==============> ] 6.523MB/23.23MB
097d8efb1a01: Pushing [==============> ] 16.76MB/57.77MB
fc617a256ca8: Pushing [======================================> ] 11.35MB/14.64MB
4de30c3ac6c2: Pushing [> ] 4.925MB/384.5MB
1fe7c48fedc6: Pushing [==================================================>] 3.072kB
291f6e44771a: Waiting
常见报错
在提交的时候提示没有tag标签
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat01 latest 66fd9bfabe82 13 hours ago 695MB
[[email protected] ~]# docker push jzyue/diytomcat:1.0
The push refers to repository [docker.io/jzyue/diytomcat]
An image does not exist locally with the tag: jzyue/diytomcat
这里需要对镜像打一个标签
[[email protected] ~]# docker tag 66fd9bfabe82 jzyue/tomcat01:1.0
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jzyue/tomcat01 1.0 66fd9bfabe82 13 hours ago 695MB
二、发布镜像到阿里云镜像仓库
1.登陆到阿里云(https://account.aliyun.com);
2.找到容器镜像服务;
3.创建命名空间;
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHLzUleNd3ZU1kMRpHW3BjMMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnLwEjMxIjMyYDM2EjMxAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
4.创建容器镜像仓库,仓库类型:公开代表所有人都可以看到;私有只有自己可以看到;
5.进入到仓库,根据阿里云的操作指南来实际操作一下。
[[email protected] ~]# sudo docker login [email protected] registry.cn-beijing.aliyuncs.com #登陆到阿里云
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[[email protected] ~]# docker images #查看镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
jzyue/tomcat01 1.0 66fd9bfabe82 14 hours ago 695MB
[[email protected] ~]# docker push jzyue/tomcat01:1.0 #推送镜像到阿里云仓库
The push refers to repository [docker.io/jzyue/tomcat01]
cd2c8c332d4e: Pushed
097d8efb1a01: Pushed
fc617a256ca8: Pushed
4de30c3ac6c2: Pushing [============================================> ] 340.6MB/384.5MB
1fe7c48fedc6: Layer already exists
291f6e44771a: Layer already exists
具体详细操作参考阿里云操作指南