0

In my docker-compose.yaml file I use the image "my-service" (among other remote images that work fine)

version: "2"
services:
  myservice:
    image: my-service

Normally I build the "my-service" image with maven using the io.fabric8 docker-maven-plugin.

My Dockerfile:

FROM vertx/vertx3-alpine
ENV VERTICLE_HOME /opt/lib
ENV NAME my-service
ENV EXEC_JAR_NAME my-service.jar
COPY target/my-service-1.0-SNAPSHOT.jar $VERTICLE_HOME/$EXEC_JAR_NAME
COPY target/lib $VERTICLE_HOME
COPY src/main/resources/settings.json /etc/company/myservice/settings.json
ENTRYPOINT ["sh", "-c"]
CMD ["java -cp $VERTICLE_HOME/$EXEC_JAR_NAME com.company.myservice.MyVerticle"]

Is there a way using the DockerComposeContainer from Testcontainers for docker-compose to use my local image of my-service?

This is my test set up

public class MyServiceIT {
    @ClassRule
    public static DockerComposeContainer compose =
            new DockerComposeContainer(new File("src/test/resources/docker-compose.yml"));

Currently I get the following error message as it is using local images.

7:15:34.282 [tc-okhttp-stream-454305524] INFO  [docker/compose:1.8.0] - STDERR: pull access denied for my-service, repository does not exist or may require 'docker login'
17:15:34.283 [main] WARN org.testcontainers.containers.DockerComposeContainer - Exception while pulling images, using local images if available

It sounds like I need to build the image for use in my test, but I am not sure how to do that.

1 Answers1

0

That's not an error message, but just a warning if docker-compose pull fails, see here.

You can also make Docker Compose build the images for you (although it is highly recommended to use withLocalCompose(true) in that case)

bsideup
  • 2,845
  • 17
  • 21
  • Thanks! You made me realize my container was actually up and running correctly. I was just expecting more logs. I was able to find and get into my container via `docker ps` to find the Container ID and then `docker exec -it bash` while the test was running. Is there a way to get more output in line in the same way you when you run `docker-compose up` from the command line? I tried to use `withTailChildContainers(true)` but that didn't seem to change anything. – hexagramoccupy Feb 15 '19 at 20:47
  • Nevermind. https://www.testcontainers.org/features/container_logs/ pointed me in the right direction. Though with DockerComposeContainer it looks like you use `withLogConsumer(servicename, logconsumer)` instead of `followOutpu(logconsumer)` – hexagramoccupy Feb 15 '19 at 23:11