tilt-dev / tilt-dev/tilt

Docker prune fails if image is both used for resource and as base image

Open
#4,596 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
10.1k
Forks
413
Avg merge
1d 10h
Merged PRs (30d)
6

Description

Expected Behavior
  • tilt docker-prune should be able to clean up all images Tilt produced
Current Behavior
  • tilt docker-prune can fail to remove images if it tagged them more than once
    [Docker Prune] cannot prune image sha256:eb853b9faada7b43bb19f47affd56b0c9db75b182fd2d7bf8df21389f1943d29 (tags: monolith-worker-tilt_docker_build_with_restart_base:tilt-eb853b9faada7b43, monolith:tilt-eb853b9faada7b43); `docker image remove --force` required to remove an image with multiple tags (Docker throws error: "image is referenced in one or more repositories")
    
Steps to Reproduce
  1. Create a Tiltfile with at least 2 docker_builds where the second one uses the first one as base image
    load("ext://restart_process", "docker_build_with_restart")
    docker_build("monolith", ".")
    docker_build_with_restart("monolith-worker", ".", dockerfile_contents="FROM monolith", entrypoint="<omitted>")
    docker_prune_settings(disable=False, max_age_mins=1, num_builds=1, keep_recent=1) 
    ...
    # bring up some k8s resources that use those images above
    
    N.B. You need a Pod with BOTH monolith AND monolith-worker
  2. Run tilt up, build a few times
  3. Stop Tilt, run tilt docker-prune
About Your Use Case

From Allon Hadaya in #tilt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the tilt docker-prune entry point and reproduce the case with two docker_builds where the second uses the first as its base image, plus a Pod using both images. Verify the fix by running tilt docker-prune after repeated builds and confirming that all eligible images are removed without requiring docker image remove --force.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.