目录
1.地址: https://hub.docker.com 注册自己的账号
发布自己的镜像
一、Dockerhub
1.地址: https://hub.docker.com 注册自己的账号
2.确定账号可以登录
3.在我们服务器上提交自己的镜像
[root@centos01 gh]# 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
[root@centos01 gh]#
4.登陆完毕后就可以提交镜像
[root@centos01 gh]# docker login -u 2495140780
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
5.docker push
#push到自己的服务器上
[root@centos01 gh]# docker push gh/jdk/tomcat
Using default tag: latest
The push refers to repository [docker.io/gh/jdk/tomcat]
ec168676a560: Preparing
c7679ce1f2ce: Preparing
0b961db77ed3: Preparing
9c131fac41e6: Preparing
74ddd0ec08fa: Preparing
denied: requested access to the resource is denied #拒绝
[root@centos01 gh]#
#解决,增加一个 tag
[root@centos01 gh]# docker tag 1a136bef8b49 gh/jdk/tomcat:1.0
#docker push山去即可! 自己发布的镜像尽量戴上版本号
[root@centos01 gh]# docker push gh/jdk/tomcat:1.0
The push refers to repository [docker.io/gh/jdk/tomcat]
ec168676a560: Preparing
c7679ce1f2ce: Preparing
0b961db77ed3: Preparing
9c131fac41e6: Preparing
74ddd0ec08fa: Preparing
二、阿里云镜像服务上
1.登录阿里云
2.找到容器镜像服务
3.创建命名空间
4.创建容器仓库
5.浏览信息
镜像上传
登录
# 登录成功
[root@gh dockerfile]# docker login --username=xxxxxxregistry.cn-qingdao.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
[root@gh dockerfile]#
修改发布镜像的版本
[root@gh java]# docker tag 20b770574f05 registry.cn-hangzhou.aliyuncs.com/gongdada/diytocmat:1.1
[root@gh java]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mytomcat 1.1 20b770574f05 27 minutes ago 801MB
diytomcat 1.1 20b770574f05 27 minutes ago 801MB
上传
[root@gh java]# docker push registry.cn-hangzhou.aliyuncs.com/gongdada/diytocmat:1.1
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/gongdada/diytocmat]
00cc4c934513: Pushing [==> ] 10.87MB/215.6MB
72df085a27ae: Pushing [==============> ] 4.688MB/16MB
99df646bb573: Pushing [> ] 4.422MB/365.3MB
ba971dbd4971: Pushed
174f56854903: Pushing [==> ] 9.779MB/203.9MB
1.1: digest: sha256:64a0c2aee5f32aba5c3c258e0a350e17ad440c7cb543047ddd7eac7ce8f0dbf8 size: 1373
下载
[root@gh dockerfile]# docker pull registry.cn-hangzhou.aliyuncs.com/gongdada/diytocmat:1.1
1.1: Pulling from gongdada/gh1234
5e0b432e8ba9: Pull complete
a84cfd68b5ce: Pull complete
e8b8f2315954: Pull complete
0598fa43a7e7: Pull complete
e0d35e3be804: Pull complete
8fc448a0c88b: Pull complete
dbdff6e5955b: Pull complete
5daf3771e3d8: Pull complete
e4265b3badfc: Pull complete
126f233cb97a: Pull complete
25b2696affa4: Pull complete