I want to build an application. For testing it uses testcontainers. The build will run on CI and on the developers' machines. The Dockerfile is more or less:
FROM amazoncorretto:17-alpine as builder
add . .
run ./gradlew build
from amazoncorretto:17-alpine
copy --from=builder build/libs/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
And I run the build using docker build .
Part of the ./gradlew build
runs tests with Testscontainers and uses
val sftpDocker = GenericContainer(DockerImageName.parse("atmoz/sftp:alpine"))
And it returns
java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
I know that:
- Testcontainers has its own docker API client and doesn't requires installed docker inside the Alpine container 3
- Someone made it using
"docker:20.10.14-dind"
image. But I don't know how it fits in my problem 4 - I can mount the
/var/run/docker.sock
duringdocker run ...
but I'm usingRUN
command inside dockerfile anddocker build ...
instead - I can expose
DOCKER_HOST
and testcontainers should use the default gateway's IP address. But it's way less secure than using socket
So is there a way to use a socket in this setup? If not, how should I run my host Docker to expose TCP instead of a socket?