Docker Community Forums

Share and learn in the Docker community.

Port not accessible, even when it's exposed/published


(Rdaems) #1

I’ve a dockker compose file to start an nginx on a VM ( RHEL 7 )
But when I leave out the network_mode:host, the OS is not listening at port 80.
Only when I set it to “host” the nginx is accessible.
I don’t know why this is necessary. Is this VM specific ?

---                                                                         
version: '2'                                                                
services:                                                                   
  nginx:                                                                    
    # network_mode: host                                                      
    restart: always                                                         
    container_name: nginx                                                   
    image: nginx:1.13                                                       
    logging:                                                                
      driver: "json-file"                                                   
      options: {                                                            
        "max-size":"5m",                                                    
        "max-file":"3"}                                                     
    expose:                                                                 
      - '80'                                                                
    ports:                                                                  
      - '80:80'                                                             
    volumes:                                                                
      - '/app/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro'        

This is the nginx config:

upstream xap_e2esi {
    server xap_e2esi:8080;
}

server {
    listen       80;

        auth_basic off;
        allow all;

    location /e2esi/ {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://xap_e2esi/;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

(Doncicuto) #2

Is the RHEL 7 VM running in a cloud service like Amazon or are you using a desktop virtualization solution (VirtualBox, libvirt…)?