Docker container not accessible in host machine

Some of my containers are running a web server (PHP, NodeJS) in production.

If we take the example of the NodeJS container, this is its configuration

  • Unable to run docker or service docker
  • Error while publising to docker on Azure from Visual Studio 2015
  • How to monitor Nodejs app running on Kubernetes
  • Docker image from shared hosting
  • How to push a docker image to a private repository
  • Link images on Docker Hub
  • docker-compose.yml

    version: '2'
        build: .
         - data
         - db:db
         - redis:redis
          - '8080:3000'
        restart: always

    With this configuration, I’m able to access to my webapp through but I cannot access on my host machine with

    $ curl localhost:8080

    I have a Nginx server on my host with this configuration:

    upstream webapp {
    server {
      listen 80;
      listen [::]:80;
      location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   HOST $http_host;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-NginX-Proxy true;
        proxy_redirect off;
        proxy_pass http://webapp;

    But acceding to throw a 504 Gateway Time-out.

    If I try to change port configuration in my docker-compose.yml by '' the problem still here but cannot access to (and but it is the result I want).

    This is very strange and I don’t have the problem running my app on a fresh server.
    I’m searching for the root of this issue.

    Thanks for your support.


    $ netstat -tunlp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address        State       PID/Program name
    tcp        0      0*               LISTEN      -               
    udp        0      0*                           -               

    Web server has to be listening on port 3000 but I have

    $ docker-compose logs
    webapp_1  | Express server listening on port 3000 in production mode

    The server is also running…

    $ docker port webapp_1
    3000/tcp ->

  • Docker on Windows Nano Server: There is not enough space on the disk
  • Cannont create lxc container with ubuntu template using lxc 1.0.0.alpha 1 on Ubuntu 13.04 Raring version
  • Azure vm docker create cannot find certificate 'ca.pem'
  • Docker - how to run mongodb process as daemon
  • How to populate table by commands in the Dockerfile
  • Having difficulty accessing the Jupyter notebook when trying to run TensorFlow through Docker
  • One Solution collect form web for “Docker container not accessible in host machine”

    Edit: This should work similar to how you have it, did you try changing:
    proxy_set_header HOST $http_host;
    proxy_set_header HOST $host;
    in your nginx config?

    You could put nginx in your Docker Compose file and let Compose use its own network. If you want to add items in another network, you can specify a custom network, see:

    Otherwise, you can look at the output of ifconfig, etc on your host and see which IP and network Compose is using and what the host is listening to.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.