-
| Hello everyone, I am having some troubles with volume mounts (FileSystemBinds and ClassPathResourceMapping) on Gitlab CI. My container: OMN_WEB = new GenericContainer<>(DockerImageName.parse(OMN_WEB_API_IT_IMAGE_NAME))
                    .withExposedPorts(OMN_WEB_PORT)
                    .withNetwork(network)
                    .withNetworkAliases(OMN_WEB_ALIAS)
                    .dependsOn(LDAP, DB)
                    .withEnv("CATALINA_OUT", DEV_STDOUT) // log to stdout
                    .withEnv("TOMCAT_STDOUT", DEV_STDOUT) // log to stdout
                    .withClasspathResourceMapping("config",
                            OMN_CONFIG_FOLDER,
                            BindMode.READ_ONLY) // read only copies files and in result leaves already existing ones
                    .withClasspathResourceMapping(DB_PROPERTIES_FILE_SOURCE,
                            OMN_CONFIG_FOLDER + "/" + DB_PROPERTIES_FILE_TARGET,
                            BindMode.READ_ONLY)
                    .withClasspathResourceMapping(OMN_WEB_CONF,
                            OMN_ETC_FOLDER + "/" + OMN_WEB_CONF,
                            BindMode.READ_ONLY)
                    .withClasspathResourceMapping("libs/",
                            OMN_PLUGINS_FOLDER,
                            BindMode.READ_WRITE) // read write mounts folder and therefore overwrites existing folder
                    .withClasspathResourceMapping("jdbc",
                            OMN_JDBC_DRIVER_FOLDER,
                            BindMode.READ_WRITE)
                    .withFileSystemBind("logs", OMN_WEB_LOG_FOLDER) // logs are in omn4-api-app/logs for debug purposes
                    .withFileSystemBind(DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), "/var/run/docker.sock", BindMode.READ_WRITE)
                    .withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(OMN_WEB_ALIAS)))
                    .waitingFor(Wait.forHttp(OMN_API_VERSION_ENDPOINT).forPort(OMN_WEB_PORT).forStatusCode(403)
                            .withStartupTimeout(Duration.ofMinutes(4)));
 OMN_WEB.start();My Gitlab CI yml: image: maven:3.5.3-jdk-8
variables:
  # Instruct Testcontainers to use the daemon of DinD.
  DOCKER_HOST: "tcp://docker:2375"
  # Instruct Docker not to start over TLS.
  DOCKER_TLS_CERTDIR: ""
  # Improve performance with overlayfs.
  DOCKER_DRIVER: overlay2
  MAVEN_OPTS: "-XX:+UseG1GC -Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
  MAVEN_COMMAND: mvn --batch-mode --errors -DinstallAtEnd=true -DdeployAtEnd=true
  FAILSAFE_REPORTS: omn4-api-app/target/failsafe-reports/*.xml
  UPSTREAM: develop
...
IT with Oracle:
  # DinD service is required for Testcontainers
  services:
    - docker:dind
  stage: test
  script:
    - ${MAVEN_COMMAND} clean verify -Pit -Ddbms.oracle -DskipUnitTests
  allow_failure: true
  artifacts:
    reports:
      junit: ${FAILSAFE_REPORTS}The Container does not start because it could not find the database JDBC driver supposed to be mounted with READ_WRITE ClassPathResourceMapping: I am using version 1.15.3: <dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>testcontainers</artifactId>
    <version>1.15.3</version>
    <scope>test</scope>
</dependency> | 
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
| Hi @shomeier, For the volume binds to work, you need to make sure that tests' file system matches Docker's. See https://www.testcontainers.org/supported_docker_environment/continuous_integration/dind_patterns/ Also, have you considered using the copy API instead of mounting files? It is generally preferred and recommended, as it works with any Docker, not only with local one | 
Beta Was this translation helpful? Give feedback.
Hi @shomeier,
For the volume binds to work, you need to make sure that tests' file system matches Docker's.
See https://www.testcontainers.org/supported_docker_environment/continuous_integration/dind_patterns/
Also, have you considered using the copy API instead of mounting files? It is generally preferred and recommended, as it works with any Docker, not only with local one