11

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?

4
  • 1
    Include your docker-compose.yml Commented Dec 24, 2015 at 19:02
  • how is include and where?
    – Rider_BY
    Commented Dec 24, 2015 at 19:03
  • 1
    @Rider_BY: alkis means that you should paste your entire docker-compose.yml file into your question so that we can see it.
    – jwodder
    Commented Dec 24, 2015 at 19:04
  • I paste my docker-compose.yml.
    – Rider_BY
    Commented Dec 24, 2015 at 19:34

1 Answer 1

10

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.

1
  • Thank you! This helped the team. The expose: - "9000" vs the old 9000:9000 did the trick 😄 Commented Aug 17, 2023 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.