microscopic-parrot-94355
01/25/2024, 3:16 PM/var/run/docker.sock
inside a docker_environment during tests?
Longer question: I've successfully set up my repo to run my tests in a docker-environment. (🎉 ) However, some integration tests use the nifty python testcontainers
package to stand up a database, which uses docker through python's docker
package. When I run tests that use this, I get errors:
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
According to a bit of online sleuthing, this error is likely due to the "docker daemon not running", which usually listens on /var/run/docker.sock
. I've installed docker into the container, and if I run with a volume mount, the usual docker commands just work:
$docker run -it --volume /var/run/docker.sock:/var/run/docker.sock my-image /bin/bash
root@ccc1e128ec75:/src/astrometry# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ccc1e128ec75 my-image "/bin/bash" 3 seconds ago Up 2 seconds affectionate_maxwell
I suspect that the tests will also "just work" if we mount the docker socket into the container. Is there a way to tell pants to do this when running the test environment?fast-nail-55400
01/25/2024, 4:10 PMdocker_environment
.fast-nail-55400
01/25/2024, 4:10 PMfast-nail-55400
01/25/2024, 4:12 PM/var/run/docker.sock
into the container using that support. But it has not landed yet, so no way to do that currently.microscopic-parrot-94355
01/25/2024, 4:13 PMmicroscopic-parrot-94355
01/25/2024, 4:13 PMfast-nail-55400
01/25/2024, 4:14 PMfast-nail-55400
01/25/2024, 4:14 PMmicroscopic-parrot-94355
01/25/2024, 4:18 PMmicroscopic-parrot-94355
01/25/2024, 4:18 PMcurved-television-6568
01/26/2024, 8:24 AMDOCKER_HOST
option... requires some configuration tweaks for the daemon config though, and may be a no-go based on security concerns for the server socket being too open.