Bru*_*ice 22 mysql docker gitlab-ci gitlab-ci-runner
我创建了两个gitlab作业:
我使用以下gitlab-ci-multi-runner配置:
concurrent = 1
check_interval = 0
[[runners]]
name = "name-ci"
url = "https://uri/ci"
token = "token"
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker:latest"
privileged = true
disable_cache = false
volumes = ["/cache"]
shm_size = 0
[runners.cache]
Run Code Online (Sandbox Code Playgroud)
测试单元作业正常工作但Sonar作业对以下消息失败:
service runner-f66e3b66-project-227-concurrent-0-docker-wait-for-service did timeout
2017-07-05T16:13:18.543802416Z mount: mounting none on /sys/kernel/security failed: Permission denied
2017-07-05T16:13:18.543846406Z Could not mount /sys/kernel/security.
2017-07-05T16:13:18.543855189Z AppArmor detection and --privileged mode might break.
2017-07-05T16:13:18.543861712Z mount: mounting none on /tmp failed: Permission denied
Run Code Online (Sandbox Code Playgroud)
当我将'runner.docker'的配置参数'privileged'更改为false时.声纳工作但测试单元失败:
service runner-f66e3b66-project-227-concurrent-0-mysql-wait-for-service did timeout
2017-07-05T15:08:49.178114891Z
2017-07-05T15:08:49.178257497Z ERROR: mysqld failed while attempting to check config
2017-07-05T15:08:49.178266378Z command was: "mysqld --verbose --help"
2017-07-05T15:08:49.178271850Z
2017-07-05T15:08:49.178276837Z mysqld: error while loading shared libraries: libpthread.so.0: cannot open shared object file: Permission denied
Run Code Online (Sandbox Code Playgroud)
"特权"的参数必须是真实的才能在docker中使用docker.但是我不明白为什么它会为像MySQL这样的服务打破许可.
这是我的gitlab-ci文件:
stage :
- test-unit
- analyse
.php_job_template: &php_job_template
image: custom_docker_image
before_script:
- eval $(ssh-agent -s) && ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
services :
- mysql
variables:
MYSQL_DATABASE: blabla
MYSQL_USER: blabla
MYSQL_PASSWORD: blabla
MYSQL_ROOT_PASSWORD: blabla
test_phpunit_dev:
<<: *php_job_template
stage: test-unit
script:
- mysql -h mysql -u blabla -pblabla <<< "SET GLOBAL sql_mode = '';"
- php composer.phar install -q
- php vendor/bin/phpunit -c tests/phpunit.xml
sonar:
stage: analyse
image: docker:1.12.6
services:
- docker:dind
script:
- docker run --rm -v `pwd`:/build -w /build letsdeal/sonar-scanner:2.7 scan -e
Run Code Online (Sandbox Code Playgroud)
如果有人知道该解决谁,欢迎你.谢谢.
我遇到了同样的问题,并且能够通过删除 MySQL (因为我在 CI 服务器上不需要它)并禁用AppArmor来解决它。在 Ubuntu 上,您可以运行:
# Remove Mysql
sudo apt-get remove mysql-server
# Disable AppArmor for MySQL
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
Run Code Online (Sandbox Code Playgroud)
来源:https://www.cyberciti.biz/faq/ubuntu-linux-howto-disable-apparmor-commands/
归档时间: |
|
查看次数: |
1381 次 |
最近记录: |