Gitlab CI/Docker:使用自定义图像进行工作

use*_*695 10 gitlab docker gitlab-ci dockerfile

这就是我做一些linter测试(eslint)的方法.

linter:
  image: ubuntu:16.04
  stage: test
  tags:
    - testing
  before_script:
    - apt-get update -y
    - apt-get install nodejs-legacy -yqq
    - apt-get install curl -yqq
    - curl https://install.meteor.com/ | sh
    - meteor npm install eslint eslint-plugin-react
  script:
    - ./node_modules/.bin/eslint --ext .js --ext .jsx .
Run Code Online (Sandbox Code Playgroud)

但有了这个,每个测试都必须将软件包安装到ubuntu映像,这需要时间.

所以我想用这个来构建一个图像.我想出了这个Dockerfile:

FROM ubuntu:16.04
RUN apt-get update -y
RUN apt-get install nodejs-legacy -yqq
RUN apt-get install curl -yqq
RUN apt-get clean && apt-get autoclean && apt-get autoremove
RUN curl https://install.meteor.com/ | sh
Run Code Online (Sandbox Code Playgroud)

然后我做

$ docker build -t linter-testing:latest .
Run Code Online (Sandbox Code Playgroud)

和这个yml文件:

linter:
  image: linter-testing:latest
  stage: test
  tags:
    - testing
  before_script:
    - meteor npm install eslint eslint-plugin-react
  script:
    - ./node_modules/.bin/eslint --ext .js --ext .jsx .
Run Code Online (Sandbox Code Playgroud)

但它失败了这个错误:

ERROR: Job failed: Error response from daemon: repository linter-testing not found: does not exist or no pull access
Run Code Online (Sandbox Code Playgroud)

那么为什么这个图像不存在,而是docker images向我展示了那个图像......

Jaw*_*wad 7

您需要编辑您的config.toml文件,该文件是在/etc/gitlab-runner您的转轮机上用下面的

[runners.docker]
  pull_policy = "if-not-present"
Run Code Online (Sandbox Code Playgroud)

在这里查看相关问题。