Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run testscontainers in Dockerfile build step #1112

Closed
modestukasai opened this issue Jan 2, 2019 · 5 comments
Closed

Cannot run testscontainers in Dockerfile build step #1112

modestukasai opened this issue Jan 2, 2019 · 5 comments

Comments

@modestukasai
Copy link

@modestukasai modestukasai commented Jan 2, 2019

Hi, this issue is created because #1110 was closed.

The code is here: https://github.com/modestukasai/spring-boot-testcontainers-docker

I have current docker file which should run gradlew build inside with docker testcontainers.

FROM docker as builder
USER root
RUN docker -v
RUN apk add --no-cache openjdk8
WORKDIR /app
COPY . .
RUN ./gradlew build -i

The problem is that docker is not started during build of docker image.

I have updated the base image to use docker image as base and install java8 on it.
I get the same result. Please see https://travis-ci.org/modestukasai/spring-boot-testcontainers-docker/builds/474334240

Thanks a lot!

@bsideup

This comment has been minimized.

Copy link
Member

@bsideup bsideup commented Jan 2, 2019

Hi again, @modestukasai!

Sorry, I'm closing this one with the same message:
You need to have a running Docker daemon in your environment. Your example is incorrect - it does not communicate with Docker daemon.
But if you put RUN docker run hello-world, you will see that there is no docker running.
You code simply prints Docker client's version.

@bsideup bsideup closed this Jan 2, 2019
@modestukasai

This comment has been minimized.

Copy link
Author

@modestukasai modestukasai commented Jan 2, 2019

Hi #bsideup,
Yes, I understand it and I'm asking you for help in this case, because your tutorial in documentation does not tell anything about how to run this in docker build step.
https://www.testcontainers.org/usage/inside_docker.html

@bsideup

This comment has been minimized.

Copy link
Member

@bsideup bsideup commented Jan 2, 2019

@modestukasai this is not an issue of Testcontainers project.

There is no docker daemon inside your build container (when you run docker build). Nothing to connect to.

Please ask a question in the Docker community, "How to run Docker commands during Dockerfile build".

@kiview

This comment has been minimized.

Copy link
Member

@kiview kiview commented Jan 2, 2019

AFAIK this is not possible Docker.

There might be other container tools that might allow this use case, but Testcontainers will only support Docker for the foreseeable future. While the use case is a very valid one (e.g. CI pipeline as part of the Docker multi-stage build), we can't support this, as long as Docker doesn't support it.

The linked docs describe how to use Testcontainers inside a running container, not during a docker build.

@modestukasai

This comment has been minimized.

Copy link
Author

@modestukasai modestukasai commented Jan 4, 2019

Thanks a lot #bsideup and #kiview. This is proper answer which I have expected :)

@piotrkosecki piotrkosecki mentioned this issue Jan 15, 2020
1 of 1 task complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.