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

docker-compose pass arbitrary build flags #7835

Closed
wants to merge 1 commit into from

Conversation

pareshmg
Copy link

@pareshmg pareshmg commented Sep 28, 2020

added a flags option to the service.build section to pass arbitrary arguments to the docker build from the docker-compose file

Resolves #6358 (see #6358 (comment))

An example of how I pass aws credentials to my docker build (used for codeartifact in my case)

services:
  worker:
    build:
      context: worker
      flags: '--secret id=aws_creds,src=${HOME}/.aws/credentials'```

@pareshmg
Copy link
Author

@ciaranmcnulty : I think this implements your suggestion.

Also, I'm new to contributing to docker-compose - I'm not quite sure how to write tests for this PR. Is there someone who can help me?

…rguments to the docker build from the docker-compose file

Signed-off-by: Paresh Malalur <pareshmg@mit.edu>
@pareshmg
Copy link
Author

@pareshmg #6510 #4235
Duplicate of #

@djmareewish : I don't understand how this is a duplicate of the --squash option. This is a more generic method to pass arbitrary flags to docker from docker-compose to help people have a route for a workaround until these parameters become official docker-compose yml syntax options. Or am I misunderstanding what you are pointing out?

@kiorky
Copy link

kiorky commented Nov 27, 2020

In the meantime, i'm just using that to parse build compose args and rely on docker CLI to DRY my builds ...

# compute the docker-compose service build: args back to docker CLI build-args
service=myserviceInComposeFile
buildargs=$(docker-compose config\
    |docker run -i --rm mikefarah/yq yq r - services.${service}.build.args -j\
    |docker run -i --rm imega/jq ".|to_entries[]|\" --build-arg \(.key)=\(.value)\"" -j)
# example: use squash which isnt possible now directly via compose
docker build --squash -t mytag . $buildargs

@glours
Copy link
Contributor

glours commented Jul 27, 2022

Thanks for taking the time to create this issue/pull request!

Unfortunately, Docker Compose V1 has reached end-of-life and we are not accepting any more changes (except for security issues). Please try and reproduce your issue with Compose V2 or rewrite your pull request to be based on the v2 branch and create a new issue or PR with the relevant Compose V2 information.

@glours glours closed this Jul 27, 2022
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

Successfully merging this pull request may close these issues.

Support for docker build --secret for build-time docker secrets.
4 participants