Reputation: 1624
Running $ docker-compose up
when I have my docker-compose.yml
as the following, everything works as expected:
app:
build: .
However when I have docker-compose.yml
as (which appears to valid within the docker-compose reference):
app:
build:
context: .
I get the following error:
$ docker-compose up
ERROR: The Compose file './docker-compose.yml' is invalid because:
app.build contains an invalid type, it should be a string
I've also tried context: "."
with no joy. Please help! Many thanks.
Upvotes: 28
Views: 29637
Reputation: 35595
A picture will better show the right way.
Upvotes: 1
Reputation: 2292
I got this error when I accidentally used dashes before my build entries (incorrect):
build:
- context: ../crafter
- dockerfile: Dockerfile
However, correct would be (without the dashes):
build:
context: ../crafter
dockerfile: Dockerfile
Upvotes: 3
Reputation: 2990
The format you're using is for Version 2. You're currently using Version 1 format.
For Version 1, Docker Compose expects a string:
app:
build: .
For Version 2, Docker Compose expects a string or object, but you must specify that your Docker Compose file is Version 2:
version: '2'
services:
app:
build:
context: .
Upvotes: 40