I use Testcontainers for writing integration tests for my APIs.
In particular, the tests concerning DBs - migrations, SQL queries.
Currently, I replacing Docker with Podman as the preferred tool for managing Containers.
Eventually, I stumbled upon the problem of configuring Testcontainers with Podman on my local machine. Here is what I discovered during the process of migration from Docker to Podman, with respect to Testcontainers:
Problem Link to heading
Testcontainers implicitly use Docker as the default container runtime. Thus, the library acts as a Docker API client.
Solution Link to heading
- We do not need to make any changes on the application code layer.
- We need to set the following 2 envvars in order to seamless switch from Docker to Podmangit:
# only for rootless Podman.
$ export TESTCONTAINERS_RYUK_DISABLED=true
# configure Docker API clients to use Podman for running containers.
$ export DOCKER_HOST=unix://$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}')
Voila!