edit: other containers run normally. docker run hello-world works fine.
I am trying to run the latest nginx docker image. It hangs indefinitely. I have tried this on 2 separate fresh install ubuntu virtual machines. 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.
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
Ctrl + c or Cmd + c, the container will be stopped.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). Running this command again will result in the complaint that 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