Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build target doesn't work in compose 1.19 #5714

Closed
lig opened this issue Feb 26, 2018 · 6 comments
Closed

Build target doesn't work in compose 1.19 #5714

lig opened this issue Feb 26, 2018 · 6 comments

Comments

@lig
Copy link

lig commented Feb 26, 2018

I have the following in docker-compose.yml:

version: '3'
services:
  app:
    build:
      context: .
      target: app

I'm using docker-compose version 1.19.0, build 9e633ef installed via pip3.

After running docker-compose build the expected result is to have the container for app service build with --target docker argument set to app.

The actual result is

ERROR: The Compose file './docker-compose.yml' is invalidbecause:
services.app.build contains unsupported option: 'target'

Related issues

I've found this issue #5322 which states in comments that the build target is supported since 1.17.

Also, I've found this issue docker/docs#6036 which states that the syntax is the same as for 2.x compose file version.

@lig
Copy link
Author

lig commented Feb 26, 2018

The issue was I've used version 3 which is not the latest from 3.x series as I thought. One needs to use at least version 3.4 for build target to work.

@lig lig closed this as completed Feb 26, 2018
@bossjones
Copy link

Just wanted to say thanks for this, for some reason I assumed if you put '3' as the version type, it would default to the latest supported version of '3' your docker client supports, but I was wrong. Doing the steps above, in my case, 3 -> 3.7 worked. ^^

@patricknelson
Copy link

patricknelson commented Sep 25, 2019

Also pretty confusing for me, since this is documented in version 2 as well. I assumed that if it was available in 2.3 then naturally it'd also automatically be available in 3. Turns out that's not the case, for some reason.

@akopchinskiy
Copy link

akopchinskiy commented Jun 10, 2020

The issue was I've used version 3 which is not the latest from 3.x series as I thought. One needs to use at least version 3.4 for build target to work.

Same error at 3.7.4

D:\WORK\Projects\api>docker-compose version
docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.1c  28 May 2019

D:\WORK\Projects\api>docker-compose up
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
services.api.build contains unsupported option: 'target'
services.synchronizer.build contains unsupported option: 'target'

@patricknelson
Copy link

@akopchinskiy in this case the version is in reference to the version of the YAML content not necessarily the version of docker-compose that you have instead.

Specifically: Did you try editing docker-compose.yml so that the first line version: '3' reads version: '3.7' instead?

@akopchinskiy
Copy link

@patricknelson

Did you try editing docker-compose.yml so that the first line version: '3' reads version: '3.7' instead?

I did try and it's working. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants