awslabs / soci-snapshotter

A containerd snapshotter plugin which enables standard OCI images to be lazily loaded without requiring a build-time conversion step.
Apache License 2.0
531 stars 55 forks source link

[BUG] Docker compose teardown fails when unrelated containers use the same images #400

Closed sparr closed 1 year ago

sparr commented 1 year ago

Describe the bug The final step of the integration tests is to tear down the docker compose environment. This will fail if a container from a different docker compose environment uses an image that this teardown tries to remove.

Steps To Reproduce

  1. Create confFile as follows:
    version: "3.7"
    services:
     registry:
      image: ghcr.io/oci-playground/registry:v3.0.0-alpha.1
  2. docker-compose -f confFile up &
  3. GO_TEST_FLAGS="-run SnapshotterStartup -count=1" make integration (specific test isn't important)
  4. Observe that the indicated test succeeds but the overall run fails during teardown:
    --- PASS: TestSnapshotterStartup (1.61s)
    PASS
    testing: 2023/02/07 16:40:38 failed integration test tear down: exit status 1
    FAIL    github.com/awslabs/soci-snapshotter/integration 26.123s

Cleanup after reproduction

  1. fg
  2. press Ctrl+C
  3. docker-compose -f confFile down --rmi all
  4. rm confFile

Expected behavior Integration test run succeeds.

Configuration (please complete the following information):

Additional context The failing step is exec.Command("docker-compose", "-f", confFile, "down", "--rmi", "all").Run() which produces this output Error response from daemon: conflict: unable to remove repository reference "[ghcr.io/oci-playground/registry:v3.0.0-alpha.1](http://ghcr.io/oci-playground/registry:v3.0.0-alpha.1)" (must force) - container fcca3f99c8a6 is using its referenced image bf427d5377cc then exits with status 1. That output is due to the other compose environment having a running container using an image that this docker-compose down --rmi all wants to remove.

turan18 commented 1 year ago

I think one possible solution is tagging our images with something like 'soci_test'. This way soci integ tests wont share any images with users. Using all or local flag should still remove the images used by the services.