简体   繁体   English

在 gitlab-ci 期间无法在 docker 中启动 MySQL 服务

[英]Unable to start MySQL service in docker during gitlab-ci

I have the following .gitlab-ci taken from the example of Laravel Dusk CI :我有以下.gitlab-ci取自Laravel Dusk CI的示例:

stages:
  - build
  - test

# Variables
variables:
  MYSQL_ROOT_PASSWORD: root
  MYSQL_USER: root
  MYSQL_PASSWORD: secret
  MYSQL_DATABASE: test
  DB_HOST: mysql
  DB_CONNECTION: mysql

build:
  stage: build
  services:
     - mysql:5.7

  image: chilio/laravel-dusk-ci:stable
  script:
    - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
    # - npm install # if you need to install additional modules from your projects package.json
    # - npm run dev # if you need to run dev scripts for example laravel mix 
  cache:
      key: ${CI_COMMIT_REF_NAME}
      paths:
        # these are only examples, you should modify them according to your project, 
        # or remove cache routines entirely, if they are causing any problems on your next builds..
        # below are 2 safe ones if you use composer install and npm install in your stage script
        - vendor
        - node_modules
         # - /resources/assets/vendors  # for example if you put your vendor node-libraries there

test:
  stage: test
  cache:
    key: ${CI_COMMIT_REF_NAME}
    paths:
      - vendor
      - node_modules
    policy: pull
    
  services:
    - mysql:5.7

  image: chilio/laravel-dusk-ci:stable
  script:
    - cp .env.example .env
    # - cp phpunit.xml.ci phpunit.xml # if you are using custom config for your phpunit tests in CI
    - configure-laravel
    - start-nginx-ci-project
    - ./vendor/phpunit/phpunit/phpunit -v --coverage-text --colors --stderr
    # - phpunit -v --coverage-text --colors --stderr # if you want to use preinstalled phpunit
    - php artisan dusk --colors --debug

  artifacts:
    paths:
      - ./storage/logs # for debugging
      - ./tests/Browser/screenshots
      - ./tests/Browser/console
    expire_in: 7 days
    when: always

However, when the runner executes the job, I keep getting the following warning:但是,当跑步者执行作业时,我不断收到以下警告:

Using Docker executor with image chilio/laravel-dusk-ci:stable ...
Starting service mysql:5.7 ...
Pulling docker image mysql:5.7 ...
Using docker image sha256:66bc0f66b7af6ba3ea96582685d3afcd6dff93c2f8999da0ffadd67b280db548 for mysql:5.7 ...
Waiting for services to be up and running...

*** WARNING: Service runner-237f18d2-project-23-concurrent-0-mysql-0 probably didn't start properly.

Health check error:
ContainerStart: Error response from daemon: Cannot link to a non running container: /runner-237f18d2-project-23-concurrent-0-mysql-0 AS /runner-237f18d2-project-23-concurrent-0-mysql-0-wait-for-service/service

Service container logs:
2018-07-11T19:49:03.214991318Z 
2018-07-11T19:49:03.215062485Z ERROR: mysqld failed while attempting to check config
2018-07-11T19:49:03.215067480Z command was: "mysqld --verbose --help"
2018-07-11T19:49:03.215070774Z 
2018-07-11T19:49:03.215073778Z mysqld: error while loading shared libraries: libpthread.so.0: cannot stat shared object: Permission denied

I've tried to set the runner to privileged in the config.toml :我试图在config.toml中将运行器设置为特权:

privileged = true

To solve the Question:要解决问题:

mysqld: error while loading shared libraries: libpthread.so.0: cannot stat shared object: Permission denied mysqld:加载共享库时出错:libpthread.so.0:无法统计共享 object:权限被拒绝

  • Step1: update your software and kernel(maybe):步骤1:更新您的软件和内核(也许):

    apt-get update && apt-get upgrade

  • Step2: install the docker dependency package: Step2:安装docker依赖package:

    • (ubuntu/debian): apt-get install apt-transport-https ca-certificates curl gnupg2 software properties-common (ubuntu/debian): apt-get install apt-transport-https ca-certificates curl gnupg2 software properties-common
    • (centos/redhat): yum-utils device-mapper-persistent-data lvm2 (centos/redhat): yum-utils device-mapper-persistent-data lvm2
  • Step3: reboot your server & restart your docker-ce:第三步:重启你的服务器并重启你的 docker-ce:

    reboot

    systemctl restart docker-ce

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM