如何在Jenkins容器内部使用docker-compose卷

问题描述 投票:0回答:1

我的Jenkins实例正在从jenkins / jenkins泊坞映像运行。通过诸如-v /var/run/docker.sock:/var/run/docker.sock的卷设置进行docker-in-docker设置,该实例能够运行容器。我还按照docker-compose安装指南中的说明,在从jenkins / jenkins映像构建的dockerfile中安装了docker-compose。

[我现在在Jenkinsfile脚本中使用docker-compose和volume时遇到问题:

version: "3"

services:
  newman_tests:
    image: postman/newman
    container_name: newman
    volumes:
      - ./postman:/etc/newman

./ postman是E2E.Tests目录中的文件夹,并在Jenkins文件中使用,如下所示:

stage ('Run E2E Tests'){     
    stage ('Test API') {
        agent any
        steps {
            dir('E2E.Tests') {
                sh "docker-compose up --force-recreate -d"
                // Wait for the test container to exit and fail build if needed
                sh "docker-compose logs -f newman"
                sh "docker wait newman"
            }
        }
        post { 
            always { 
                dir('E2E.Tests') {
                    sh "docker-compose down"
                    archiveArtifacts artifacts: 'postman/newman/*.html'
                }
            }
        }
    }
}

在我自己的机器上,此docker-compose在该文件夹中完美运行。在Jenkins运行的newman容器中,/etc/newman文件夹不包含任何内容。该卷似乎未正确安装。

我错过了任何配置吗?在几篇文章中,我找到了这种精确的方法,但是我认为它们没有在容器内运行jenkins本身。

docker jenkins docker-compose docker-in-docker
1个回答
0
投票
您找到了解决问题的方法吗?我有同样的问题。
© www.soinside.com 2019 - 2024. All rights reserved.