Reputation: 4214
Here is my docker-compose.yml:
version: "3"
services:
drupal:
image: drupal
ports:
- "8080:80"
volumes:
- drupal-modules:/var/www/html/modules
- drupal-profiles:/var/www/html/profiles
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=mypasswd
volumes:
drupal-modules:
drupal-profiles:
drupal-sites:
drupal-themes:
As I run
$ docker-compose up
I get:
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
Unsupported config option for services.drupal: 'postgres'
what's the problem?
Upvotes: 0
Views: 8608
Reputation: 4214
SOLVED
Every time you see
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
Unsupported config option for
it is likely the problem lies in wrong indent, as this is the case.
First, both postgres
and drupal
are containers (so services
), and so they must have the same indent level, that is, one indentation level less than services
.
Put one indentation level less to the whole postgres
structure/tree.
Second, every element starting with -
must have one indent level more than the element it belongs to.
So add one more indent level to the elements of ports
and volumes
.
Here is the docker-compose.yml corrected:
version: "3"
services:
drupal:
image: drupal
ports:
- "8080:80"
volumes:
- drupal-modules:/var/www/html/modules
- drupal-profiles:/var/www/html/profiles
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=mypasswd
volumes:
drupal-modules:
drupal-profiles:
drupal-sites:
drupal-themes:
Upvotes: 1
Reputation: 4123
Indentation in your docker-compose.yml
is not correct, since .yml
files are indent-sensitive.
You have three errors:
ports
is a key:value
data, so -
should be indented in the next line.volumes
is a key:value
data, so -
should be indented in the next line.postgres
service's indentation should be in the same level as drupal
.So your file should look like this to work:
version: "3"
services:
drupal:
image: drupal
ports:
- "8080:80"
volumes:
- drupal-modules:/var/www/html/modules
- drupal-profiles:/var/www/html/profiles
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=mypasswd
volumes:
drupal-modules:
drupal-profiles:
drupal-sites:
drupal-themes:
Upvotes: 1