2

我将一个卷绑定到我的 GenericContainer 如下:

@Container    
public GenericContainer ap = new GenericContainer(DockerImageName.parse("myImage:latest"))
                                     .withExposedPorts(AP_PORT)
                                     .withEnv("SPRING_PROFILES_ACTIVE", "integrationtest")
                                     .withFileSystemBind("/home/user/tmp/rdf4jRepos/", "/mnt/spring/", BindMode.READ_WRITE)
                                     .withLogConsumer(new Slf4jLogConsumer(log))
                                     .waitingFor(Wait.forHttp("/actuator/health"));

但我有一个权限被拒绝的问题。我在 GenericContainer 中运行的 spring-boot 应用程序中添加了以下内容:(rdfRepositoryHome = /mnt/spring)

File repoHome = new File(rdfRepositoryHome);
System.out.println( "getAbsolutePath: " + repoHome.getAbsolutePath());
File f2 = new File(repoHome, "testRepo");
System.out.println( "repoHome.isDirectory(): " + repoHome.isDirectory() );
System.out.println( "Execute: " + repoHome.canExecute() );
System.out.println( "Write: " + repoHome.canWrite() );
System.out.println( "READ: " + repoHome.canRead() );

输出:

2021-08-04 16:11:31.566  INFO 326439 --- [tream-274971679] d.f.i.s.p.a.i.ITReadProfile              : STDOUT: getAbsolutePath: /mnt/spring
2021-08-04 16:11:31.567  INFO 326439 --- [tream-274971679] d.f.i.s.p.a.i.ITReadProfile              : STDOUT: repoHome.isDirectory(): true
2021-08-04 16:11:31.567  INFO 326439 --- [tream-274971679] d.f.i.s.p.a.i.ITReadProfile              : STDOUT: Execute: true
2021-08-04 16:11:31.567  INFO 326439 --- [tream-274971679] d.f.i.s.p.a.i.ITReadProfile              : STDOUT: Write: false
2021-08-04 16:11:31.567  INFO 326439 --- [tream-274971679] d.f.i.s.p.a.i.ITReadProfile              : STDOUT: READ: true        

如何绑定可写的卷?

谢谢

2021 年 8 月 19 日更新:
我向另一个项目添加了一个测试,该项目是公开的:

在镜像上运行:
maven:3.6.1-jdk-11

  1. .gitlab-ci.yml
  2. 测试用例
  3. Dockerfile
  4. 测试作业线 117
  5. 测试作业线 1800

更新 30.8.2021:
问题应该是可重现的(独立于 gitlab ci 和 DinD!)

git clone https://gitlab.com/linkedopenactors/loa-suite.git
git checkout feature/testcontainer
cd loa-suite/
mvn clean install -DskipTests
cd integrationtests/
mvn -Dit.test=ITLastSync verify
4

0 回答 0