testcontainers / testcontainers/testcontainers-java

Creating Testcontainer from custom image doesn't work

Open
#831 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

resolution/acknowledged type/question
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

I'm writing tests for my room-service and i need the image-service because the room-service has dependencies on the image-service. this is my file tree:

+---image-service
¦   ¦   Dockerfile
¦   ¦   pom.xml
¦   ¦
¦   +---src
¦   ¦   +---main
¦   ¦   ¦   +---java
¦   ¦   ¦   +---resources
¦   ¦   +---test
¦   ¦       +---java
¦   ¦           +---de
¦   ¦               +---fh
¦   ¦                       ApplicationTest.java
+---room-service
¦   ¦   Dockerfile
¦   ¦   pom.xml
¦   ¦
¦   +---src
¦   ¦   +---main
¦   ¦   ¦   +---java
¦   ¦   ¦   +---resources
¦   ¦   +---test
¦   ¦       +---java
¦   ¦       ¦   +---de.fh
¦   ¦       ¦           ApplicationTest.java
¦   ¦       ¦
¦   ¦       +---resources
¦   ¦               application.yml

In my ApplicationTest in room-service I try to create a generic container from the dockerfile in /image-service/Dockerfile:

@BeforeClass
public static void init() {
    eurekaContainer = new GenericContainer(new ImageFromDockerfile("image-service")
            .withFileFromFile("./image-service", new File("../image-service/Dockerfile")));

    eurekaContainer.start();
}

I couldn't find any use cases like this in the documentation.
Am I using the wrong method? Are any of the paths I used wrong?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with room-service/src/test/java/.../ApplicationTest.java and the referenced image-service/Dockerfile. Check how ImageFromDockerfile and withFileFromFile resolve paths and run the room-service test; done means the custom image builds and the container starts successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
devops, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.