使用自定义图像进行作业

使用自定义图像进行作业

本文介绍了Gitlab CI/Docker:使用自定义图像进行作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

This is how I do some linter test (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 .

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

But with this every test will have to install the packages to the ubuntu image, which takes time.

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

So I thought to build a image with exact this. I came up with this 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

那我做

$ docker build -t linter-testing:latest .

还有这个 yml 文件:

and this yml file:

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 .

但它失败并出现此错误:

But it fails with this error:

ERROR: Job failed: Error response from daemon: repository linter-testing not found: does not exist or no pull access

那么为什么这个图像不存在,尽管 docker images 向我显示了那个图像...

So why is this image not existing, althoug docker images shows me exact that image...

推荐答案

您需要编辑 /etc/gitlab-runner 中的 config.toml 文件您的跑步机具有以下内容

You need to edit your config.toml file which is in /etc/gitlab-runner on your runner machine with the following

[runners.docker]
  pull_policy = "if-not-present"

查看相关问题此处.

这篇关于Gitlab CI/Docker:使用自定义图像进行作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 19:25