我正在尝试下载并启动一个Docker容器,如下所示:

docker run -it -p 8000:8000 -p 8060:8060 -h sandbox somegithubrepo bash

但是,下载过程中途停止,我得到以下信息:
docker: unauthorized: authentication required.
See 'docker run --help'.

所以我看了一下这里:
docker unauthorized: authentication required - upon push with successful login

我尝试了这个:
docker push  mydockerhubusername/somerepo:latest

但是我得到了:
The push refers to a repository [docker.io/mydockerhubusername/somerepo]
An image does not exist locally with the tag: mydockerhubusername/somerepo

我的~/.docker/config.json看起来像这样:
{
        "auths": {
                "https://index.docker.io/v1/": {
                        "auth": "someKey"
                }
        }
}

那么如何下载该容器?

最佳答案

您不下载容器。您下载图像,然后对该图像执行docker run,然后启动容器。为此,镜像必须存在于某个地方-在某些Docker注册表中,例如公共(public)DockerHub或您的私有(private)注册表或本地计算机中。如果本地计算机上不存在它,docker run会默认尝试从DockerHub或从私有(private)注册表(如果您已登录)从docker pull对其进行docker push

如果要将镜像从本地计算机推送到注册表,则必须登录到计算机上的该注册表,创建存储库,构建镜像,然后将镜像docker run java到该存储库中,以便您可以下载它从其他地方开始一个容器。当然,要构建镜像,您将需要一个Dockerfile或项目中的一些插件来自动为您构建它。

例如:Java镜像已经发布,并且我的机器上没有该镜像,因此当我执行docker pull时,它开始对official DockerHub repository中的镜像进行ojit_code:

~ $: docker run java
Unable to find image 'java:latest' locally
latest: Pulling from library/java
386a066cd84a: Pull complete
...
...
...
Status: Downloaded newer image for java:latest

关于docker - docker :未授权:需要身份验证,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40980824/

10-16 17:04
查看更多