我正在按照这个链接创建我的第一个docker映像,它成功了,现在我试图从这个链接将这个映像推到我的docker存储库中。但是每当我试图将这个映像推入存储库时,我就会得到这种类型的错误。

denied: requested access to the resource is denied

注:我已成功登录docker


当前回答

有一个docker文件,要求是立即构建一个映像并将其推送到docker hub

登录Docker集线器 Sudo docker login -u your_username 输入密码 构建映像 Sudo docker build -t your_username/demorepo:1.0 上面没有提到图像名称,因为your_username/demorepo是一个 在docker中心回购。标签名称为1.0 推送图片 Sudo docker推送your_username/demorepo:1.0

将已经存在的图像推送到Docker中心

Login to the Docker hub sudo docker login -u your_username Enter password Tag your image(suppose your image is named as test_docker:1.0) sudo docker tag test_docker:1.0 your_username/demorepo:firstpush Above, firstpush is the tag name given to your image, test_docker with 1.0 Tag. IMPORTANT : (While tagging, the image name is not mentioned) Now in docker images you will have 2 images, one says test_docker 1.0 and the other your_username/demorepo firstpush Push the image sudo docker push your_username/demorepo:firstpush

其他回答

DR docker登录在macOS上不工作,但从应用程序的docker登录工作

当直接从终端使用时,命令docker登录成功地要求我的凭据,在我正确输入它们之后(记住没有电子邮件,只有docker ID将工作),它宣布登录成功,但任何推送请求将以拒绝告终:请求访问资源被拒绝

然而,当我从正在运行的macOs docker应用程序登录时(工具栏中的图标),它工作了。因此,docker登录和运行的docker应用程序/守护进程之间可能会有一些不一致

在我的例子中,sudo -E处理此消息失败。解决方案是提供访问do docker而不使用sudo(创建一个组docker,将(Jenkins)用户添加到组中,将组设置在/var/run/docker.sock上)。现在docker push不需要sudo了,而且可以工作。

您可能需要在docker push之前将docker repo切换为private。

感谢Dean Wu提供的答案和ses的评论,在推送之前,请记得注销,然后从命令行登录到您的docker hub帐户

# you may need log out first `docker logout` ref. https://stackoverflow.com/a/53835882/248616
docker login

根据文件:

You need to include the namespace for Docker Hub to associate it with your account.
The namespace is the same as your Docker Hub account name.
You need to rename the image to YOUR_DOCKERHUB_NAME/docker-whale.

所以,这意味着你必须在推送之前标记你的图像:

docker tag firstimage YOUR_DOCKERHUB_NAME/firstimage

然后你就可以推它了。

docker push YOUR_DOCKERHUB_NAME/firstimage

Docker登录参数在~/. Docker /config。Json应该正确设置(这是在登录后自动完成)

1)不传递SERVER参数登录:

$ echo "<password>" | docker login -u foo --password-stdin

成功登录后,在~/.docker/config中会出现如下结果。Json和push image成功。

***
"https://index.docker.io/v1/": {
    "auth": "YWNhcm***"
}
***

2)登录时传递SERVER参数index.docker.io

$ echo "<password>" | docker login index.docker.io -u foo --password-stdin

成功登录后,在~/.docker/config中会出现如下结果。Json和push image失败。

***
"index.docker.io": {
    "auth": "YWNhcm***"
}
***

docker处理用户id和存储库的方式可能有点令人困惑。 假设您在docker hub上创建了一个用户帐户xyz。新帐户自动建立名称空间xyz。 然后创建一个名为myrepo的存储库。存储库名称实际上是xyz/myrepo。

要推送一个图像,你应该做:

docker push docker.io/xyz/myrepo

如果需要,可以添加“:latest”或其他标签。

如果你得到的资源访问请求被拒绝错误消息:

访问https://hub.docker.com/并以xyz登录。 单击存储库xyz/myrepo。 点击合作者。 添加xyz作为合作者。