Score:0

Nginx can't be reached inside the docker container. What have I left out?

us flag

I've run out of ideas as to why I can't connect to this nginx inside or outside of the docker. I can understand that networking might cause a problem outside the machine, but even inside the docker nginx is not responding even though you can see it running and listening (inside the docker). Outside the docker, maybe the port isn't mapping thru but it seems to be configured such that it should.

"Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },

On the HOST machine

root@host:~# docker ps
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS               NAMES
0be6e751cd6d        humanyze/nginx:config-pentest   "nginx -g 'daemon of…"   8 seconds ago       Up 8 seconds        80/tcp              inspiring_boyd

root@host:~# wget http://localhost
--2021-09-14 22:56:32--  http://localhost/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.

root@host:~# netstat -an | grep LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN

And even though nginx is not installed on the host, this still shows up

root@host:~# ps ax | grep nginx
 4102 ?        Ss     0:00 nginx: master process nginx -g daemon off;
 4134 ?        S      0:00 nginx: worker process

And inside the docker

root@host:~# docker exec -it 0be6e751cd6d sh

/ # netstat -an | grep LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 :::80                   :::*                    LISTEN

/ # ps ax | grep nginx
    1 root      0:00 nginx: master process nginx -g daemon off;
    5 nginx     0:00 nginx: worker process
   12 root      0:00 grep nginx

/ # wget http://localhost
Connecting to localhost (127.0.0.1:80)
Connecting to localhost (127.0.0.1:443)
wget: can't connect to remote host (127.0.0.1): Connection refused
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.