我创建了两个gitlab作业:
Wen我使用以下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]
测试单元作业正常工作但声纳作业对以下消息失败:
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
当我更改配置参数'特权' ' runner.docker'为假。声纳工作但测试单元失败:
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
param"特权"必须是真的能够在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
如果有人知道该解决这个问题,欢迎您。 感谢。
答案 0 :(得分:0)
我遇到了同样的问题,并且能够通过删除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
来源:https://www.cyberciti.biz/faq/ubuntu-linux-howto-disable-apparmor-commands/
答案 1 :(得分:0)
例如为什么不使用ciricihq/gitlab-sonar-scanner
?
不需要使用Dind或特权模式