我有下面的管道,它将与 MYSQL 容器一起运行实际容器来运行测试。
stage('Test - To check MYSQL connect') {
def dockerfile = 'Dockerfile.test'
def mysql = docker.image('mysql:5.6').run('-e MYSQL_ALLOW_EMPTY_PASSWORD=yes')
docker.build("rds-test", "-f ${dockerfile} .")
def rds_test_image = docker.image('rds-test')
rds_test_image.inside("--link ${mysql.id}:mysql "){
sh 'echo "Inside Container"'
}
}
我被以下错误困住了
Successfully tagged rds-test:latest
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . rds-test
.
[Pipeline] withDockerContainer
Jenkins seems to be running inside container d4e0934157d5eb6a9edadef31413d0da44e0e3eaacbb1719fc8d47fbf0a60a2b
$ docker run -t -d -u 1000:1000 --link d14340adbef9c95483d0369857dd000edf1b986e9df452b8faaf907fe9e89bf2:mysql -w /var/jenkins_home/workspace/test-jenkinsfile-s3-rds-backup --volumes-from d4e0934157d5eb6a9edadef31413d0da44e0e3eaacbb1719fc8d47fbf0a60a2b -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** rds-test cat
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: Failed to run image 'rds-test'. Error: docker: Error response from daemon: Cannot link to a non running container: /sharp_sanderson AS /fervent_lewin/mysql.
以防万一您想查看 rds-test dockerfile https://github.com/epynic/rds-mysql-s3-backup/tree/feature