简体   繁体   English

无法在本地找到图像“hello-world:latest”

[英]Unable to find image 'hello-world:latest' locally

I have installed docker in my machine following the official installation steps for ubuntu.按照 ubuntu 的官方安装步骤,我已经在我的机器上安装了 docker。 At the verification steps it fails.在验证步骤中它失败了。

When I run the command: docker run hello-world it throws following error message:当我运行命令时: docker run hello-world 它会抛出以下错误消息:

Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry- 
1.docker.io/v2/: net/http: request canceled while waiting for 
connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.  

Below are the docker details for my machine.以下是我机器的 docker 详细信息。

Client: Docker Engine - Community
Version:           19.03.6
API version:       1.40
Go version:        go1.12.16
Git commit:        369ce74a3c
Built:             Thu Feb 13 01:27:49 2020
OS/Arch:           linux/amd64
Experimental:      false
Got permission denied while trying to connect to the Docker daemon socket at 
unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version: dial unix 
/var/run/docker.sock: connect: permission denied

If I tried for docker info I got the following message:如果我尝试获取 docker 信息,则会收到以下消息:

Client: Debug Mode: false客户端:调试模式:假

Server: ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/info : dial unix /var/run/docker.sock: connect: permission denied errors pretty printing info服务器:错误:尝试连接到 unix:///var/run/docker.sock 的 Docker 守护进程套接字时获得权限被拒绝:获取http.ockFvar1.run%2info/docker:%2Fvar1.run%2info拨打 unix /var/run/docker.sock:连接:权限被拒绝错误漂亮的打印信息

First check if docker is running using首先检查 docker 是否正在使用

sudo service docker status须藤服务 docker 状态

If its running, then you probably missed out adding your user to docker group.如果它正在运行,那么您可能错过了将您的用户添加到 docker 组。 To confirm this, try docker commands with sudo要确认这一点,请尝试使用sudo执行 docker 命令

If you don't want to use sudo every time follow below guide to add you user to docker group如果您不想每次都使用sudo ,请按照以下指南将您添加到 docker 组

Step 2 — Executing the Docker Command Without Sudo (Optional) 第 2 步 — 在不使用 Sudo 的情况下执行 Docker 命令(可选)

NOTE: You can not run Docker in WSL ie Ubuntu on Windows, so you need to install docker for windows, following guide provided complete steps of using Docker in WSL. NOTE: You can not run Docker in WSL ie Ubuntu on Windows, so you need to install docker for windows, following guide provided complete steps of using Docker in WSL.

Setting Up Docker for Windows and WSL to Work Flawlessly 为 Windows 和 WSL 设置 Docker 以完美工作

Post installation steps of docker are probably not executed. docker 的安装后步骤可能没有执行。 Basically, the current logged in used need to be added to docker group.基本上,当前登录使用的需要添加到docker组。

Just follow the instructions here from docker documentation - https://docs.docker.com/engine/install/linux-postinstall/只需按照 docker 文档中的说明进行操作 - https://docs.docker.com/engine/install/linux-postinstall/

FYA- group membership evaluation would happen only after a reboot of ubuntu (in 18.04). FYA-组成员资格评估只会在 ubuntu(在 18.04 中)重新启动后进行。 So, after following the above link, reboot ubuntu machine.因此,按照上述链接后,重新启动 ubuntu 机器。 Then try docker images and permission issue reported should get resolved.然后尝试docker images和报告的权限问题应该得到解决。

This problem has solved when I upgrade my ubuntu 19.04 to 19.10 and then reinstall it.当我将 ubuntu 19.04 升级到 19.10 然后重新安装时,此问题已解决。

I had similar problem, while trying to fix the below error,我有类似的问题,在尝试修复以下错误时,

root@neno88:/home/mohan# docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/ : dial tcp: lookup registry-1.docker.io on 10.187.215.112:53: read udp 10.187.215.103:58777->10.187.215.112:53: read: connection refused. root@neno88:/home/mohan# docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/ : dial tcp: lookup registry-1.docker.io on 10.187.215.112:53: read udp 10.187.215.103:58777->10.187.215.112:53: read: connection refused.

So, The error was due to the proxy in my enterprise setup, the daemon requests are refused via proxy所以,错误是由于我的企业设置中的代理,守护程序请求通过代理被拒绝

WRONG TRY to fix it, ( which caused error like above.) I have added the registry-1.docker.io ip to the /etc/hosts, but it caused the similar error as in this StackOverflow here.错误地尝试修复它,(导致上述错误。)我添加了 registry-1.docker.io ip 到 /etc/hosts 中的类似错误。

root@neno88:/home/mohan# docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/ : net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers). root@neno88:/home/mohan# docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/ : net /http:在等待连接时请求被取消(等待标头时超出了 Client.Timeout)。 See 'docker run --help'.请参阅“docker run --help”。 root@neno88:/home/mohan# root@neno88:/home/mohan#

CORRECT STEPS: How to fix it,正确的步骤:如何解决它,

  1. Just add your Proxy details to the /etc/systemd/system/docker.service.d/proxy.conf (folder docker.service.d may not exists, so create the directory before)只需将您的代理详细信息添加到 /etc/systemd/system/docker.service.d/proxy.conf (文件夹 docker.service.d 可能不存在,所以之前创建目录)
  2. After adding the proxy details check using the below commands, whether the daemon successfully see/read your environment variables.使用以下命令添加代理详细信息检查后,守护程序是否成功查看/读取您的环境变量。

$ sudo systemctl daemon-reload $ sudo systemctl 守护进程重载

$ sudo systemctl restart docker $ sudo systemctl 重启 docker

$ systemctl show --property=Environment docker $ systemctl show --property=环境 docker

Refer this doc: https://www.serverlab.ca/tutorials/containers/docker/how-to-set-the-proxy-for-docker-on-ubuntu/请参阅此文档: https://www.serverlab.ca/tutorials/containers/docker/how-to-set-the-proxy-for-docker-on-ubuntu/

You can simply pull and test it in this way:您可以通过以下方式简单地拉取和测试它:

$ sudo docker pull hello-world
$ sudo docker run hello-world

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM