Docker无法使用mysql

时间:2018-07-17 10:45:02

标签: mysql laravel docker testing gitlab-ci

我正在尝试使用gitlab的CI(连续集成)对Laravel项目进行自动测试(使用Dusk)。

但是在初始化composer

之后,我总是遇到此错误

ERROR: Job failed (system failure): Error response from daemon: Cannot link to a non running container: /runner-0a53e0ab-project-30-concurrent-0-mysql-0 AS /runner-0a53e0ab-project-30-concurrent-0-predefined-5/mysql

使用的版本

我正在使用docker( 18.03.1-ce )管理所有内容。

我有Gitlab( 10.0.3 )和gitlab-runner( 11.0 )。我还发现了这个docker image,对于我的用例来说似乎很完美。

我不使用docker-compose(因此this thread不适用于我)。

警告

我在一开始也有这个警告

Running with gitlab-runner 11.0.0 (5396d320)
  on my-web-runner 0a53e0ab
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:c356247174ed09823171ae537fd70273900103f2474c2eb62d8782ececcba7ab for mysql:5.7 ...
Waiting for services to be up and running...

*** WARNING: Service runner-0a53e0ab-project-30-concurrent-0-mysql-0 probably didn't start properly.

Health check error:
service "runner-0a53e0ab-project-30-concurrent-0-mysql-0-wait-for-service" timeout

但是容器创建得很好,警告之后我也有这些信息

Service container logs:
2018-07-17T08:15:15.332803346Z Initializing database
2018-07-17T08:15:18.023855458Z 2018-07-17T08:15:18.020174Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-07-17T08:15:18.979992069Z 2018-07-17T08:15:18.979239Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-07-17T08:15:19.697917282Z 2018-07-17T08:15:19.697211Z 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: 8b6ce71e-8999-11e8-aee6-0242ac110003.
2018-07-17T08:15:19.839972447Z 2018-07-17T08:15:19.838426Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

.gitlab-ci.yml

我正在使用此 .gitlab-ci.yml

构建所有内容
stages:
  - build
  - test

# Variables
variables:
  MYSQL_ROOT_PASSWORD: my_pw
  MYSQL_USER: my_user
  MYSQL_PASSWORD: my_pw
  MYSQL_DATABASE: testing_db
  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

test:
  stage: test
  cache:
    key: ${CI_BUILD_REF_NAME}
    paths:
      - vendor
      - node_modules
    policy: pull

  services:
    - mysql:5.7

  image: chilio/laravel-dusk-ci:stable
  script:
    - cp .env.example .env
    - configure-laravel
    - start-nginx-ci-project
    - php artisan dusk

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

尝试

  • 我尝试重新启动整个计算机,然后重新启动docker服务
  • 我删除了所有内容并从头开始重建
  • 我用--privileged发射了亚军,并检查了config.toml
  • 我按照here的说明尝试了3个版本的chilio / laravel-dusk

日志

这是gitlab运行器容器的日志

# docker logs gitlab-runner
Starting multi-runner from /etc/gitlab-runner/config.toml ...  builds=0
Running in system-mode.

Configuration loaded                                builds=0
WARNING: 'metrics_server' configuration entry is deprecated and will be removed in one of future releases; please use 'listen_address' instead
Metrics server disabled
Checking for jobs... received                       job=29 repo_url=http://gitlab.local/Customize/Web.git runner=0a53e0ab
ERROR: Job failed (system failure): Error response from daemon: Cannot link to a non running container: /runner-0a53e0ab-project-30-concurrent-0-mysql-0 AS /runner-0a53e0ab-project-30-concurrent-0-predefined-5/mysql  job=29 project=30 runner=0a53e0ab

1 个答案:

答案 0 :(得分:0)

尝试重新启动容器; docker restart gitlab-runner

根据最新的GitLab requirements

检查服务器