Why can't I connect to this docker container?

I’ve got a java servlet container running in edge_web_1 which I can access on port 8080 and I can’t access 80 or 443 on edge_nginx_1. Any ideas?

    # docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                      NAMES
    99c26fe2117e        nginx:1             "nginx -g 'daemon ..."   27 minutes ago      Up 27 minutes>80/tcp,>443/tcp   edge_nginx_1
    571ef4787dbc        edge_web            "/tmp/"     27 minutes ago      Up 27 minutes>8080/tcp                     edge_web_1
    7f0c15522a70        mongo:3             "/ mo..."   58 minutes ago      Up 27 minutes       27017/tcp                                  edge_db_1

From the docker host:

    # curl localhost:8080
    {"code":404,"message":"HTTP 404 Not Found"}

(The json response means I’m through to the servlet container, a 404 is fine for this).

    # curl localhost:80
    curl: (52) Empty reply from server

I get the same for 443. I’ve tried using 18080 instead of 80 in case it was something to do with privileged ports. The host is created using docker-machine with the digitalocean driver. The containers are configured with docker-compose and it all works both locally and with the virtualbox driver.

Curiously (to me) on virtualbox docker-machine set things up to run as the docker user, on digitalocean it seems to run as the root user. The iptables rules are very different too, but the digitalocean ones look no different for 80 than 8080.

    # iptables -L -n
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination
    Chain FORWARD (policy DROP)
    target     prot opt source               destination
    DOCKER-ISOLATION  all  --  
    DOCKER     all  --  
    ACCEPT     all  --              ctstate RELATED,ESTABLISHED
    ACCEPT     all  --  
    ACCEPT     all  --  
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination
    Chain DOCKER (1 references)
    target     prot opt source               destination
    ACCEPT     tcp  --             tcp dpt:8080
    ACCEPT     tcp  --             tcp dpt:443
    ACCEPT     tcp  --             tcp dpt:80
Chain DOCKER-ISOLATION (1 references)
target     prot opt source               destination
RETURN     all  --  

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


Now if I run the last few commands you provided:

docker-machine rm edgee
docker-machine create --driver digitalocean --digitalocean-access-token xxxx --digitalocean-region "ams3" edgee
eval $(docker-machine env edgee)
docker-compose -f test.yml up

… that doesn’t work (using my own token, of course) and the connection fails both locally and when trying to connect from the web to the public IP.

Checking the logs on the container reports absolutely nothing

docker logs edgee

And it appears to be running fine, but it just doesn’t respond. I checked the firewall on my end and nothing appears to be preventing the connection, it simply doesn’t respond, so I’m trying to see if there’s something I’m simply overlooking.


To get a better idea of how things were setup and allow troubleshooting, can you post the details on how and what you used to setup the container? (i.e. build file(s), the compose file, command(s) ran to create, etc) – as well as any configuration for NGINX.