edit:其他容器正常运行。docker运营的helloworld运行良好。
我正在尝试运行最新的nginx docker镜像。它无限期地挂着。我已经在两个单独的全新安装的ubuntu虚拟机上尝试过了。我不知道该怎么办。如有任何帮助,我们将不胜感激。
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
...
它挂在最后。
以及一些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
当您执行此命令docker run nginx:latest
时,您实际上是在附加模式下运行它,这意味着
- 来自stdout和stderr的所有日志都将打印在屏幕上
- 如果使用
Ctrl + c
或Cmd + c
退出命令,则容器将停止
因此,命令似乎挂起了,因为不再打印日志了。
您可以尝试运行以下命令,而不是
docker run -it -d
--name nginx_container
-p 80:80
-p 443:443
nginx:latest
注意,这个命令将创建一个在后台运行的名为nginx_container
的nginx容器(分离模式(。再次运行此命令将导致投诉The container name "/nginx_container" is already in use by container
。
要停止并移除该容器,请运行以下命令
docker stop nginx_container
docker rm nginx_container