Open trajano opened 1 year ago
My workaround for Docker desktop is https://stackoverflow.com/a/76842771/242042
This is specifically for Docker Desktop for Windows. First you need to expose the Docker daemon
docker run -p 2375:2375 -v //var/run/docker.sock://var/run/docker.sock alpine/socat tcp-listen:2375,reuseaddr,fork unix-connect:/var/run/docker.sock
Then in your Dockerfile you have
ENV DOCKER_HOST=tcp://host.docker.internal:2375
ENV TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal
RUN gradle --no-daemon test
I have tested on Linux with the bind mount no luck still
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 0ec2159a-9e97-4835-9cf4-7427f9526e4b::snj9qtt8vlr50m3fsd24nntto: "/var/run/docker.sock": not found
I second this. Is there a specific reason the UNIX socket is not bind-mountable for the builder whereas it is for docker run?
+1 - running testcontainers during build step could be very helpful
Description
In order for tools like TestContainers to work inside a
docker build
it would need access to a docker daemon. I triedto no avail, likely because I am on Windows. What I would propose is
Which will provide the
/var/run/docker.sock
during the run and will adapt to the current context. However, it can be extended to allow other contexts aside from the current.rel: https://stackoverflow.com/questions/76842452/how-do-i-access-var-run-docker-sock-inside-docker-build