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

denied: requested access to the resource is denied

注:我已成功登录docker


当前回答

使用以下命令:

$ docker login
<enter user name and password for Docker Hub Repository>

$ docker tag first-image {docker-hub-username}/{default-repo-folder-name}:first-image

$ docker push {docker-hub-username}/{default-repo-folder-name}:first-image

例如,我有像manjeet86/docker-repo这样的公共存储库,所以命令将是:

$ docker tag first-image manjeet86/docker-repo:first-image

$ docker push manjeet86/docker-repo:first-image

你看:而不是/这就是窍门。这对我很管用。我不知道它是否让你用/来代替:,但这可能是出于其他目的。

https://docs.docker.com/engine/reference/commandline/tag/#examples

其他回答

有一个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

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

不知道docker hub发生了什么,但没有一个解决方案对我有效。以下是截至2018年1月,我最终管用的变通办法:

访问hub.docker.com并将存储库更改为private 在你的shell中:

码头工人的图片

存储库标记映像id创建大小 1.975 GB 1.955 GB 1.954 GB

docker 标签 bb38976d03cf dockhub用户名/verse_gapminder:mytag

Docker登录Docker .io

docker push dockhusersername /verse_gapminder:mytag

回到docker hub,将repo更改为public。 这对我很管用。

我有一个类似的问题,我通过创建一个具有相同映像名称的存储库来解决它,然后将它推到docker,它工作了

您可能需要在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