Docker Community Forums

Share and learn in the Docker community.

Docker-compose.yml errors

docker
build

(Gabrie) #1

Hi
Trying to use a docker-compose.yml file to build three images and containers. But I’m running into a strange error and I can’t find what is wrong.

My docker-compose.yml file:

version: '2'
services:
GabeThermDB:
build:
  context: ./GabeThermDB
  dockerfile: Dockerfile

GabeThermApache:
build:
  context: ./GabeThermApache
  dockerfile: Dockerfile
  ports:
   - "80:80"

GabeThermPHPMyAdmin:
build:
  context: ./GabeThermPHPMyAdmin
  dockerfile: Dockerfile
  ports:
   - "8080:80"

When I run docker-compose up, I get the following errors:
ERROR: The Compose file ‘./docker-compose.yml’ is invalid because:
services.GabeThermPHPMyAdmin.build contains unsupported option: 'ports’
services.GabeThermApache.build contains unsupported option: ‘ports’

I can’t see what is wrong. I already removed all the tabs by spaces.

Regards
Gabrie


(Gabrie) #2

Found the problem. The spaces and indents are very important :frowning:


(Jérémy Jumeau) #3

Yes !
I suggest you to use 4 spaces indention :wink:

Here is your example with a valid format:

version: '2'
services:
    GabeThermDB:
        build:
            context: ./GabeThermDB
            dockerfile: Dockerfile

    GabeThermApache:
        build:
            context: ./GabeThermApache
            dockerfile: Dockerfile
        ports:
            - "80:80"

    GabeThermPHPMyAdmin:
        build:
            context: ./GabeThermPHPMyAdmin
            dockerfile: Dockerfile
        ports:
            - "8080:80"