写在前面:以下内容是基于 阿里云服务器 | 系统centos7.6 为基础展开的!
目录
1. 官方Push镜像
1.首先登录自己DockerHub账号
[root@liustudy tomcat]# docker login -u liusirstudy
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-storeLogin Succeeded
2. 将要 push 的镜像名设置 tag
docker tag 【镜像名】用户名/自定义名称:【tag】
eg: docker tag [镜像名] liusirstudy/tomcat:1.0
3. 发布镜像 docker push liusirstudy/tomcat:1.0

==》push成功!
2.阿里云 push 镜像
1.首先登录阿里云账号
[root@liustudy /]# docker login --username=羽鑫墨鑫轩 registry.cn-hangzhou.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-storeLogin Succeeded
2.将要 push 的镜像名设置 tag
[root@liustudy /]# docker tag feb5d9fea6a5 registry.cn-hangzhou.aliyuncs.com/liustudy/study_test:1.0
命令组成:
docker tag 【镜像名】registry.cn-hangzhou.aliyuncs.com/命名空间/仓库名:【tag】
举例:push docker 的hello-world 到服务器
3.push 镜像到服务器
docker push registry.cn-hangzhou.aliyuncs.com/liustudy/study_test:1.0
4.查看效果

3.解决错误不是一蹴而就
在push 镜像到阿里服务器的过程中尝试了很多方法:
1.登录阿里云服务器后,不设置 registry.cn-hangzhou.aliyuncs.com

我以为登录后默认在这个里面了 ,结果不是,还是需要加上这个;
[root@liustudy /]# docker tag feb5d9fea6a5 liustudy/study_test:1.0
[root@liustudy /]# docker push liustudy/study_test:1.0
The push refers to repository [docker.io/liustudy/study_test]
e07ee1baac5f: Preparing
denied: requested access to the resource is denied
2.自定义名也不可以,阿里必须走 /命名空间/仓库,这里区别官方的,官方的是 用户名/自己命名:版本!
[root@liustudy /]# docker tag feb5d9fea6a5 liusir/hello:1.0
[root@liustudy /]# docker push liusir/hello:1.0
The push refers to repository [docker.io/liusir/hello]
e07ee1baac5f: Preparing
denied: requested access to the resource is denied
本文档详细介绍了如何将Docker镜像推送到DockerHub和阿里云容器镜像服务的过程,包括登录、设置tag和push操作。同时,针对在推送过程中遇到的权限拒绝问题进行了分析和解决,强调了阿里云镜像推送需指定完整命名空间和仓库路径。
1万+

被折叠的 条评论
为什么被折叠?



