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

  • Difficulty accessing Docker's API
  • Docker API call returns “server gave HTTP response to HTTPS client”
  • How to pass parameters from docker to angular js?
  • Type “geometry” does not exists [duplicate]
  • Docker error on an entrypoint script: “no such file or directory”
  • What's the difference between Kubernetes and Flynn/Deis
  • 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 ->

  • Nodemon Doesn't Restart in Windows Docker Environment
  • alpine linux docker image, console encoding trouble
  • Container Based Application Clustering System
  • Invalid repository name while pulling an image in docker
  • “Unable to write in the cache directory” with Docker and Nginx
  • Docker environment variable security
  • 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.