Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build contains unsupported option: 'ports'

Trying to use docker-compose for the first time, but not having much luck. I have the following setup: docker-compose version 1.8.0, build f3628c7

  • /home/GabeThermComposer contains the docker-compose.yml
  • /home/GabeThermComposer/GabeThermApache contains Dockerfile
  • /home/GabeThermComposer/GabeThermPHPMyAdmin contains Dockerfile
  • /home/GabeThermComposer/GabeThermDB contains Dockerfile and nest-init.sql

When I create docker images using the Dockerfile in each subdir, it all works without issues. I was hoping with the docker-compose.yml to do all the seperate building of images at once.

The docker-compose.yml looks like this:

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 trying to run "docker-compose up", I get the following error:

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 have no clue on what is wrong with this. I think I did exactly as other examples have shown. Btw, I do know that the "context:" and "dockerfile:" is overdone, but since I'm new, I wanted to be sure to what files I'm pointing in case I forget it automatically dives into the subdir and runs the Dockerfile.

Any help is appreciated.

like image 537
Gabrie Avatar asked Dec 01 '22 16:12

Gabrie


1 Answers

You have to move the ports out of the build block.

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"
like image 163
Johannes Merz Avatar answered Dec 04 '22 04:12

Johannes Merz