Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose build error

If I use command docker-compose build, I'll get error that looks like:

ERROR: Validation failed in file './docker-compose.yml', reason(s):
Service 'php' configuration key 'expose' '0' is invalid: should be of
the format 'PORT[/PROTOCOL]'

I use the last version docker and docker-compose.

My docker-compose.yml has the next code:

application:
    build: code
    volumes:
        - ./symfony:/var/www/symfony
        - ./logs/symfony:/var/www/symfony/app/logs
    tty: true
db:
    image: mysql
    ports:
        - 3306:3306
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: symfony
        MYSQL_USER: root
        MYSQL_PASSWORD: root
php:
    build: php-fpm
    expose:
        - 9000:9000
    volumes_from:
        - application
    links:
        - db
nginx:
    build: nginx
    ports:
        - 80:80
    links:
        - php
    volumes_from:
        - application
    volumes:
        - ./logs/nginx/:/var/log/nginx
elk:
    image: willdurand/elk
    ports:
        - 81:80
    volumes:
        - ./elk/logstash:/etc/logstash
        - ./elk/logstash/patterns:/opt/logstash/patterns
    volumes_from:
        - application
        - php
        - nginx

I use an ubuntu 14.04 Could you tell me how is fix it?

like image 399
Rider_BY Avatar asked Dec 24 '15 18:12

Rider_BY


1 Answers

You need to put the port definitions in quotes for short ports (2 digits). This is a result of the nature of YAML and the used parser in docker-compose.

application:
    build: code
    volumes:
        - ./symfony:/var/www/symfony
        - ./logs/symfony:/var/www/symfony/app/logs
    tty: true
db:
    image: mysql
    ports:
        - "3306:3306"
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: symfony
        MYSQL_USER: root
        MYSQL_PASSWORD: root
php:
    build: php-fpm
    expose:
        - "9000"
    volumes_from:
        - application
    links:
        - db
nginx:
    build: nginx
    ports:
        - "80:80"
    links:
        - php
    volumes_from:
        - application
    volumes:
        - ./logs/nginx/:/var/log/nginx
elk:
    image: willdurand/elk
    ports:
        - "81:80"
    volumes:
        - ./elk/logstash:/etc/logstash
        - ./elk/logstash/patterns:/opt/logstash/patterns
    volumes_from:
        - application
        - php
        - nginx

Also the expose statement should come with a single number only and also be quoted. Added all needed changes in the above.

like image 81
Armin Braun Avatar answered Oct 29 '22 23:10

Armin Braun