测试容器 - 即时创建图像问题:复制似乎没有按预期工作

问题描述

/我正在使用 testcontainers 1.14.3 来执行集成测试。测试代码如下:

@Container
private static final GenericContainer<?> wildfly = new GenericContainer(
  new ImageFromDockerfile().withDockerfileFromBuilder(builder -> builder
    .from("jboss/wildfly:20.0.1.Final")
    ...
    .copy("./customization/com","/opt/jboss/wildfly/modules/com")
    ...
    .build()));
  ...

这应该等同于以下 Dockerfile:

FROM jboss/wildfly:20.0.1.Final
...
COPY ./customization/com /opt/jboss/wildfly/modules/com
...

当使用 docker build 或 dockerfile-maven-plugin 运行时,上面的 Dockerfile 可以工作。但是,运行集成测试会引发以下异常:

Feb 17,2021 4:41:30 PM org.junit.jupiter.engine.execution.JupiterEngineExecutionContext close
SEVERE: Caught exception while closing extension context: org.junit.jupiter.engine.descriptor.ClassExtensionContext@58e92c23
org.testcontainers.containers.ContainerLaunchException: Container startup failed
...
Caused by: com.github.dockerjava.api.exception.DockerClientException: Could not build image: COPY failed: stat /var/lib/docker/tmp/docker-builder455520120/customization/com: no such file or directory

这里似乎发生的是,复制命令在 docker builder 中查找源目录,即在容器中,而不是在主机上。它没有找到它,当然,它还没有,因为我实际上正在复制它。

关于为什么会发生以及如何修复它的任何建议?

非常感谢。

西摩

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...