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
Subscribe
Share

Hi, I am trying to use the example provided in the site https://docs.docker.com/compose/gettingstarted/

Step 3: Define services Define a set of services using docker-compose.yml:

Create a file called docker-compose.yml in your project directory and add the following:

version: '2'
services:
  web:
    build: .
    ports:
     - "5000:5000"
    volumes:
     - .:/code
    depends_on:
     - redis
  redis:
    image: redis

and when I run the command docker-compose up i got the below error

ERROR: yaml.scanner.ScannerError: while scanning for the next token found character ‘\t’ that cannot start any token in “./docker-compose.yml”, line 18, column 1 so i removed all spaces and modified it as below

Defines two web services, web and redis

version: ‘2’ services: web: build: . #Build from the dockerfile from current dir ports:

  • “5000:5000” #Forward the exposed port 5000 on the container to port 5000 on the host machine volumes:
  • .:/code #Mounts the project directory on the host to /code inside the container directory allowing you to modify the code without having to rebuild the image depends_on:
  • redis redis: image: redis #Links the webservice to the redis service

on trying it again i am getting an error now as

docker-compose up ERROR: In file ‘./docker-compose.yml’, service must be a mapping, not a NoneType.

Can I get some help what is wrong here… I am using MAC.


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

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.

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