[英]docker run nginx:latest hangs indefinitely
edit: other containers run normally.编辑:其他容器正常运行。 docker run hello-world works fine.
docker run hello-world 工作正常。
I am trying to run the latest nginx docker image.我正在尝试运行最新的 nginx docker 映像。 It hangs indefinitely.
它无限期地挂起。 I have tried this on 2 separate fresh install ubuntu virtual machines.
我已经在 2 个单独的全新安装 ubuntu 虚拟机上尝试过这个。 I have no idea how to proceed.
我不知道如何继续。 Any help would be appreciated.
任何帮助,将不胜感激。
docker run nginx:latest
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
68ced04f60ab: Already exists
28252775b295: Already exists
a616aa3b0bf2: Already exists
Digest: sha256:2539d4344dd18e1df02be842ffc435f8e1f699cfc55516e2cf2cb16b7a9aea0b
Status: Downloaded newer image for nginx:latest
...
...and it hangs at the end. ...它挂在最后。
and some netstat to verify that ports 80 and 443 are free.和一些 netstat 来验证端口 80 和 443 是否空闲。
sudo netstat -tulpn
[sudo] password for josh:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 387/systemd-resolve
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 471/cupsd
tcp6 0 0 ::1:631 :::* LISTEN 471/cupsd
udp 0 0 127.0.0.53:53 0.0.0.0:* 387/systemd-resolve
udp 0 0 0.0.0.0:68 0.0.0.0:* 6179/dhclient
udp 0 0 0.0.0.0:631 0.0.0.0:* 685/cups-browsed
udp 0 0 0.0.0.0:46233 0.0.0.0:* 485/avahi-daemon: r
udp 0 0 0.0.0.0:5353 0.0.0.0:* 485/avahi-daemon: r
udp6 0 0 :::5353 :::* 485/avahi-daemon: r
udp6 0 0 :::35115 :::* 485/avahi-daemon: r
When you execute this command docker run nginx:latest
you are actually running it in the attached mode which means当你执行这个命令
docker run nginx:latest
你实际上是在附加模式下运行它,这意味着
Ctrl + c
or Cmd + c
, the container will be stopped.Ctrl + c
或Cmd + c
退出命令,容器将停止。 As a result, it seems like the command hangs because there is no log being printed out anymore.结果,命令似乎挂起,因为不再打印任何日志。
You can try to run the following command instead您可以尝试运行以下命令
docker run -it -d \
--name nginx_container \
-p 80:80 \
-p 443:443 \
nginx:latest
Note that this command will create a running nginx container with the name nginx_container
running in the background (detached mode).请注意,此命令将创建一个名为
nginx_container
正在运行的 nginx 容器在后台运行(分离模式)。 Running this command again will result in the complaint that The container name "/nginx_container" is already in use by container
.再次运行此命令将导致抱怨
The container name "/nginx_container" is already in use by container
。
To stop and remove that container, run the following command要停止并删除该容器,请运行以下命令
docker stop nginx_container
docker rm nginx_container
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.