Question

Docker bridge network & Docker-compose "yaml.parser.ParserError"

Hi everyone! I have an Ubuntu 14 machine with Nginx and Docker… Nginx is set to listen to localhost:80 and forwarding requests to Docker’s network, where is running a container with a second Nginx and a Laravel App.

  1. if i use the default docker bridge network, i always get problem with communications between nginx on ubuntu machine and the container into docker’s network. When i try to set up the “host_binding_ipv4” parameter i get this error back: “error response from Deamon: driver failed programming external connectivity on endpoint. Error starting userland proxy: listen tcp 0.0.0.0:80” note that i want to modify that 0.0.0.0 ip in something like 173.17.0.1 but unsuccessfully. How can i forward the requests to the docker container?

  2. Now i’m trying to use a docker-compose configuration like seguent:

version: '2'                          
                                      
services:                             
                                      
service_laravel:                      
    container_name: service_laravel   
    restart: always                   
    build:                            
        context: .                    
        dockerfile: Dockerfile        
    networks:                         
        docker1:                      
            ipv4_address: 173.17.0.2  
        ports:                        
            - 8000:80                 
                                      
networks:                             
    docker1:                          
        driver: bridge                
        ipam:                         
            driver: default           
        config:                       
            - subnet: 173.17.0.0/16   
            gateway: 173.17.0.1       

…with this nginx configuration…

#Ubuntu Nginx 
server {                                                               
                                                                      
   listen 80;                                                         
   server_name localhost;                                             
                                                                      
   # Proxying the connections                                         
   location / {                                                       
       proxy_pass         http://173.17.0.1:8000;                     
       proxy_redirect     off;                                        
       proxy_set_header   Host $host;                                 
       proxy_set_header   X-Real-IP $remote_addr;                     
       proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for; 
       proxy_set_header   X-Forwarded-Host $server_name;              
   }                                                                  
}            

…i have a Dockerfile that build the container with laravel and Nginx… but i get this error when i run “docker-compose up”

ERROR: yaml.parser.ParserError: while parsing a block collection
  in "./docker-compose.yml", line 23, column 13
expected <block end>, but found '?'
  in "./docker-compose.yml", line 24, column 13
Show comments

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.

Yaml weirdness, but try aligning your subnet and gateway tags:

version: '2'                          

services:                             
    service_laravel:                      
        container_name: service_laravel   
        restart: always                   
        build:                            
            context: .                    
            dockerfile: Dockerfile        
        networks:                         
            docker1:                      
                ipv4_address: 173.17.0.2  
            ports:                        
                - 8000:80                 

networks:                             
    docker1:                          
        driver: bridge                
        ipam:                         
            driver: default           
        config:                       
            - subnet: 173.17.0.0/16   
              gateway: 173.17.0.1