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)...
Connecting to localhost (localhost)||:80... failed: Connection refused.

root@host:~# netstat -an | grep LISTEN
tcp        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    *               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 (
Connecting to localhost (
wget: can't connect to remote host ( Connection refused

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.