深浅模式
发布镜像
DockerHub
注册dockerhub https://hub.docker.com/signup,需要有一个账号
shell
# 1、查看登录命令
[root@notebox tomcat]# docker login --help
Usage: docker login [OPTIONS] [SERVER]
# 2、登录
[root@notebox tomcat]# docker login -u notebox
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
# 3、将镜像发布出去
[root@notebox tomcat]# docker push notebox/diytomcat:1.0
The push refers to repository [docker.io/library/diytomcat]
0f02399c6fdf: Preparing
e79ea0c3a34e: Preparing
09281fa8fe38: Preparing
b56a902b0aef: Preparing
0683de282177: Preparing
# 拒绝:请求的资源访问被拒绝
denied: requested access to the resource is denied
# 问题:本地镜像名无帐号信息,解决加 tag即可
docker tag 251ca4419332 notebox/diytomcat:1.0
# 再次 push, ok
[root@notebox tomcat]# docker push notebox/diytomcat:1.0
The push refers to repository [docker.io/notebox/diytomcat]
0f02399c6fdf: Pushing [========> ]
9 .729MB/59.76MB
e79ea0c3a34e: Pushing [==========> ]
3 .188MB/15.41MB
09281fa8fe38: Pushing [> ]
3 .823MB/324MB
b56a902b0aef: Pushed
0683de282177: Pushing [=> ]
5 .997MB/237.1MB阿里云镜像服务
- 1、登录阿里云
- 2、找到容器镜像服务

3 、创建命名空间

4 、创建镜像仓库


5 、点击进入这个镜像仓库,可以看到所有的信息

6 、测试推送发布
shell
[root@notebox tomcat]# docker login --username=18225148644 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
# 2、设置 tag
docker tag [ImageId] registry.cn-beijing.aliyuncs.com/bilibili-notebox/notebox-test:[镜像版本号]
[root@notebox tomcat]# docker tag 251ca4419332 registry.cn-beijing.aliyuncs.com/bilibili-notebox/notebox-test:v1.0
# 3、推送命令
docker push registry.cn-beijing.aliyuncs.com/bilibili-notebox/notebox-test:[镜像版本号]
[root@notebox tomcat]# docker push registry.cn-beijing.aliyuncs.com/bilibili-notebox/notebox-test:v1.07 、在阿里云镜像仓库查看效果!

总结

