Repository navigation
Replies: 1 comment 1 reply
|
If your Dockerfile (image build) is small, doesn't have many layers, and doesn't rely heavily on BuildKit features, you can use the Testcontainers' image builder. You can configure it that the resource reaper (Ryuk) also cleans up intermediate layers and deletes the image. I usually don't recommend this because of limitations in the Docker Engine API (we can't take advantage of BuildKit). There are two other approaches. If you build the image as shown in your example (it looks a bit unconventional), you can use The other approach is to slightly change how you build the image and start your own resource reaper instance that specifically takes care of cleaning up the image. |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
First of all, thank you for this amazing project 👏🏻
Within a NUnit test, I want to achieve the following:
Dockerfile).I want to execute #3 to not leave any remnants in case there are no errors. Otherwise, I end up with 50 Docker images when executing the test 50 times (in case it succeeds).
However, in case there are errors, I don't want the built image to be deleted, so I can reproduce what went wrong (via the unique tag).
I wrote some code which at least handles the happy case (i.e. remove the built image):
Expand to see my code
While that works nicely, it feels to me that I now "compete" with the Testcontainers runtime for my app container's state handling - instead of letting Testcontainers handle the shutdown of my app's container, I do this so that I can remove the image.
Therefore, I'm wondering whether Testcontainers offers a smarter solution instead of my rather manual approach 🤔
I appreciate your help!
All reactions