Commit Graph

11 Commits

Author SHA1 Message Date
Nicolas De Loof 0f5b5ccbd0 detect replacement container is created and inform printer so it attach and don't stop
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-02-06 11:23:13 +01:00
Milas Bowman bc806da712 build: label built images for reliable cleanup on `down`
When running `compose down`, the `--rmi` flag can be passed,
which currently supports two values:
 * `local`: remove any _implicitly-named_ images that Compose
            built
 * `all`  : remove any named images (locally-built or fetched
            from a remote repo)

Removing images in the `local` case can be problematic, as it's
historically been done via a fair amount of inference over the
Compose model. Additionally, when using the "project-model"
(by passing `--project-name` instead of using a Compose file),
we're even more limited: if no containers for the project are
running, there's nothing to derive state from to perform the
inference on.

As a first pass, we started labeling _containers_ with the name
of the locally-built image associated with it (if any) in #9715.
Unfortunately, this still suffers from the aforementioned problems
around using actual state (i.e. the containers might no longer
exist) and meant that when operating in file mode (the default),
things did not behave as expected: the label is not available
in the project since it only exists at runtime.

Now, with these changes, Compose will label any images it builds
with project metadata. Upon cleanup during `down`, the engine
image API is queried for related images and matched up with the
services for the project. As a fallback for images built with
prior versions of Compose, the previous approach is still taken.

See also:
 * https://github.com/docker/compose/issues/9655
 * https://github.com/docker/compose/pull/9715

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-09-07 17:57:29 -04:00
Ulysses Souza 55cf579e02 Fix `down` with `--rmi`
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-08-29 19:48:23 +02:00
Nicolas De Loof 48a6dc088b
rebuild compose project from labels
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-20 09:00:47 +02:00
Nicolas De Loof 1ae9b3cb5d
move compose-cli code into docker/compose/v2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-08-31 19:09:19 +02:00
Nicolas De Loof 58bfbbb288
introduce ImageDigestLabel to track image built for service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-08-25 10:03:51 +02:00
Lorena Rangel 15f07f2e13 Revert "introduce ImageDigestLabel to track image built for service"
Signed-off-by: Lorena Rangel <lorena.rangel@docker.com>
2021-08-09 17:27:23 +02:00
Nicolas De Loof 64cea4fab3
introduce ImageDigestLabel to track image built for service
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-08-06 16:14:03 +02:00
Nicolas De Loof 399f6cde5e
document public variable
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-06-17 15:35:50 +02:00
Nicolas De Loof df9fa2d2d8
better interoperability with docker-compose on version label
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-06-16 14:40:33 +02:00
Nicolas De Loof d90495e1cd move compose API into pkg/api
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-06-15 15:52:48 +02:00