docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.96k stars 5.22k forks source link

"Custom build outputs" support #9586

Open tpict opened 2 years ago

tpict commented 2 years ago

Are there any plans to support Docker's custom build outputs, either via a flag to docker-compose build or in the Compose file? Thanks!

ndeloof commented 1 year ago

How would docker compose up handle this, if you configure build output to write image to a local tar file, to create a container for service after a successful build ? At most, such an option could only be available for docker compose build. is this what you are asking for ? Maybe docker compose build --output type=tar,dest=some_path could generate image files as some_path/.tar`?

ndeloof commented 1 year ago

created a draft PR to add support for custom build outputs, please give it a try and let me know if this covers your need https://github.com/docker/compose/pull/10642

Aarbel commented 1 year ago

It would be extremely useful

image

Docker outputs on docker-compose doesn't show all necessary informations. In this cas, i absolutely don't know which container is "eca8ccf1c84e"

ndeloof commented 1 year ago

@Aarbel your comment is unrelated to custom build output, feel free to open a dedicated issue (and include docker inspect eca... for diagnostic

ndeloof commented 6 months ago

Closing as obsolete. Requested feature is unclear how this would benefit docker compose usage

Ryanf55 commented 6 months ago

Here is my use case:

For Custom Build Output here, it is useful for me to take the build logs and test artifacts created during docker build and expose them back to the host so they can be uploaded into Gitlab as a CI artifact. Currently, I create these with docker build command. I would like to migrate everything to compose, but this lack of supports for outputs makes the migration impossible.

gegles commented 5 months ago

Hello, I was just directed to this and yes, we would really need this as well... We leverage docker compose extensively for dev, test, build and prod... We especially use a complex multi stage build.

Having docker compose helps us encapsulating what would otherwise be pretty complex docker build or run commands..

One of the stage of the build is to to create official binaries (RPM/DEB packages). We can even build multiple archs (amd64, arm64, s390x and ppc64le) thanks to the platform field...

But, sadly, custom build outputs (--output arg) is not supported by docker compose and thus we end up with a pretty complicated build command:

docker buildx build --secret id=conan_password,env=CONAN_PASSWORD --secret id=conan_login_username,env=CONAN_LOGIN_USERNAME --ssh=default --target packages --output=build/linux --platform linux/amd64 --platform linux/arm64 .

Even though all those things are also defined in the compose.yaml.

Please add the output field to the compose spec. 🙏🏻 . Thanks!

ndeloof commented 5 months ago

@gegles use docker buildx bake so you don't need this long command line and can reuse declarations from your compose file