带有testContainer的Bitbucket管道无法正常工作

发布于 2025-02-04 14:57:46 字数 2281 浏览 5 评论 0原文

尝试使用测试容器运行Bitbucket管道时,我会面临此错误

无法启动容器java.lang.illegalstateexception:容器 无法正确启动。

没有其他问题,但也许与绑定有关?日志:

“ hostconfig”:“ binds”:[“/opt/opt/atlassian/pipelines/agent/build/src/test/resources:/opt/opt/atlassian/pipelines/agent/agent/agent/build/src/test/test/resources:rw“,rw”, “ /var/run/docker.sock /docker.sock :rw“]

pipelines config:

pipelines:
  pull-requests:
    '**':
       - step:
           name: Integration tests
           caches:
              - maven
           after-script:
              - pipe: atlassian/checkstyle-report:0.3.0
           script:
              - export TESTCONTAINERS_RYUK_DISABLED=true
              - export TESTCONTAINERS_CHECKS_DISABLE=true
              - mvn -B verify -Dsurefire.skip=true --file pom.xml
           services:
              - docker
       - step:
           name: Build
           caches:
              - maven
           after-script:
              - pipe: atlassian/checkstyle-report:0.3.0
           script:
              - mvn -B package --file pom.xml -DskipTests
           services:
              - docker
definitions:
   services:
      docker:
         memory: 3072

docker-compose.yml

services:
  db:
    image: postgres:14.1
    ports:
       - "5432:5432"
    expose:
       - "5432"
    networks:
       - example-network
    environment:
       - "POSTGRES_USER=${DB_USER:-postgres}"
       - "POSTGRES_PASSWORD=${DB_PASSWORD:-postgres}"
       - "POSTGRES_DB=${DB_SCHEMA:-testdb}"
    logging:
       driver: json-file
       options:
          mode: "non-blocking"
 networks:
    example-network:
       driver: bridge

docker docker compose compose compose coptaine:

    DOCKER_COMPOSE_CONTAINER =
        new DockerComposeContainer(new File("src/test/resources/docker-compose.yml"))
                .withExposedService(SERVICE_NAME, SERVICE_PORT, 
    Wait.forListeningPort());
    DOCKER_COMPOSE_CONTAINER.start();

我也没有testcontainers_checks_checks_disable = true = true,但是那里是错误的

状态403:{“消息”:“插件管道拒绝授权:-v仅支持$ bitbucket_clone_dir及其子目录”}

任何人都可以帮忙吗?

I face this error when try to run bitbucket pipelines with test container

Could not start container java.lang.IllegalStateException: Container
did not start correctly.

There is no another issues but maybe it's related to Binds? Logs:

"HostConfig":"Binds":["/opt/atlassian/pipelines/agent/build/src/test/resources:/opt/atlassian/pipelines/agent/build/src/test/resources:rw","/var/run/docker.sock:/docker.sock:rw"]

Pipelines config:

pipelines:
  pull-requests:
    '**':
       - step:
           name: Integration tests
           caches:
              - maven
           after-script:
              - pipe: atlassian/checkstyle-report:0.3.0
           script:
              - export TESTCONTAINERS_RYUK_DISABLED=true
              - export TESTCONTAINERS_CHECKS_DISABLE=true
              - mvn -B verify -Dsurefire.skip=true --file pom.xml
           services:
              - docker
       - step:
           name: Build
           caches:
              - maven
           after-script:
              - pipe: atlassian/checkstyle-report:0.3.0
           script:
              - mvn -B package --file pom.xml -DskipTests
           services:
              - docker
definitions:
   services:
      docker:
         memory: 3072

docker-compose.yml

services:
  db:
    image: postgres:14.1
    ports:
       - "5432:5432"
    expose:
       - "5432"
    networks:
       - example-network
    environment:
       - "POSTGRES_USER=${DB_USER:-postgres}"
       - "POSTGRES_PASSWORD=${DB_PASSWORD:-postgres}"
       - "POSTGRES_DB=${DB_SCHEMA:-testdb}"
    logging:
       driver: json-file
       options:
          mode: "non-blocking"
 networks:
    example-network:
       driver: bridge

docker compose container:

    DOCKER_COMPOSE_CONTAINER =
        new DockerComposeContainer(new File("src/test/resources/docker-compose.yml"))
                .withExposedService(SERVICE_NAME, SERVICE_PORT, 
    Wait.forListeningPort());
    DOCKER_COMPOSE_CONTAINER.start();

I also tried without TESTCONTAINERS_CHECKS_DISABLE=true but there was error like

Status 403: {"message":"authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectories"}

Could anyone help with this please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的影子我的梦 2025-02-11 14:57:46

正如您收到的错误消息所解释的那样,Bitbucket Pipelines Docker Engine仅允许您的项目源的子目录。

我不知道为什么您打算安装/var/run/docker.sock,或者是否可以避免它,但是Bitbucket通常将Docker Engine转发到产卵容器中,例如,管道中的是通过设置,

...
--env=DOCKER_HOST="tcp://host.docker.internal:2375" \
--add-host="host.docker.internal:$BITBUCKET_DOCKER_HOST_INTERNAL" \
...

因此可能需要模仿那。

As the error message you got explains, Bitbucket Pipelines Docker engine only lets mounting subdirectories of your project sources.

I don't know why you intend to mount /var/run/docker.sock or if you can avoid it, but the way Bitbucket usually forwards the Docker engine to spawned containers, e.g. in pipes, is by setting

...
--env=DOCKER_HOST="tcp://host.docker.internal:2375" \
--add-host="host.docker.internal:$BITBUCKET_DOCKER_HOST_INTERNAL" \
...

so might need to imitate that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文