请帮助我,我尝试在詹金斯制作管道项目。 我需要dmstr / php-yii2,mysql:5个容器来运行我的应用程序
node('lm.backend.test') { checkout scm docker.image('mysql:5').withRun('-e "MYSQL_ROOT_PASSWORD=my-secret-pw"'){ c -> docker.image('mysql:5').inside("--link ${c.id}:db") { sh 'service mysql start' } docker.image('dmstr/php-yii2').inside("--link ${c.id}:db") { sh 'php -v' sh 'mysql -v' stage('Build') { sh 'cd basic && composer dump-autoload && composer clear-cache && composer install' } stage('TEST API'){ sh 'cd basic && vendor/bin/codecept build && vendor/bin/codecept run' } } } stage('Deploy'){ echo 'Deploying....' } }
结果
+ docker run -d -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:5 Unable to find image 'mysql:5' locally 5: Pulling from library/mysql 85b1f47fba49: Pulling fs layer 27dc53f13a11: Pulling fs layer 095c8ae4182d: Pulling fs layer ... Status: Downloaded newer image for mysql:5 ... + service mysql start 2017-10-26T13:13:19.717210Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-10-26T13:13:20.596078Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-10-26T13:13:20.784780Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-10-26T13:13:20.867922Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7061064d-ba4f-11e7-8f0f-0242ac110003. 2017-10-26T13:13:20.874019Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-10-26T13:13:20.884048Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. 2017-10-26T13:13:22.427363Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. 2017-10-26T13:13:22.427401Z 1 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode. 2017-10-26T13:13:22.427411Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-10-26T13:13:22.427428Z 1 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode. 2017-10-26T13:13:22.427435Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-10-26T13:13:22.427445Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-10-26T13:13:22.427480Z 1 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode. 2017-10-26T13:13:22.427490Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. ... $ docker stop --time=1 b4a8a716f4aa142b142a458b7ef5b26a241b0afb8c0ad60440558e64a4f8393f $ docker rm -f b4a8a716f4aa142b142a458b7ef5b26a241b0afb8c0ad60440558e64a4f8393f [Pipeline] // withDockerContainer [Pipeline] sh [live-monitors-control_new-CALN2TMKEXYXFJOAARVVINY7KIIEDLY2MJOL4IZEPHIXNJTTWPXA] Running shell script + docker stop e59fc8bfc4d6a9214b90dbc7a0c8ba0915cf0f05b0799e36cbc986fe792d904d e59fc8bfc4d6a9214b90dbc7a0c8ba0915cf0f05b0799e36cbc986fe792d904d + docker rm -f e59fc8bfc4d6a9214b90dbc7a0c8ba0915cf0f05b0799e36cbc986fe792d904d e59fc8bfc4d6a9214b90dbc7a0c8ba0915cf0f05b0799e36cbc986fe792d904d [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code -1 Finished: FAILURE
答案 0 :(得分:0)
如果你试图在mysql容器中运行php容器,你可以尝试将docker sock挂载到mysql容器中。
mysqlimage.inside('-v /var/run/docker.sock:/var/run/docker.sock')
{
phpimage.inside()
{
..........
}
}
我从来没有尝试过,但它可以奏效。