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: label built images for reliable cleanup on down #9819

Merged
merged 5 commits into from
Sep 14, 2022

Commits on Sep 7, 2022

  1. 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 docker#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:
     * docker#9655
     * docker#9715
    
    Signed-off-by: Milas Bowman <milas.bowman@docker.com>
    milas committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    bc806da View commit details
    Browse the repository at this point in the history

Commits on Sep 13, 2022

  1. down: refactor image pruning

    Signed-off-by: Milas Bowman <milas.bowman@docker.com>
    milas committed Sep 13, 2022
    Configuration menu
    Copy the full SHA
    680763f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b49b9ff View commit details
    Browse the repository at this point in the history
  3. small cleanup + godoc

    Signed-off-by: Milas Bowman <milas.bowman@docker.com>
    milas committed Sep 13, 2022
    Configuration menu
    Copy the full SHA
    403d691 View commit details
    Browse the repository at this point in the history
  4. add license to file

    Signed-off-by: Milas Bowman <milas.bowman@docker.com>
    milas committed Sep 13, 2022
    Configuration menu
    Copy the full SHA
    8016786 View commit details
    Browse the repository at this point in the history