docker - Gitlab CI/Docker : Use custom image for job

标签 docker gitlab dockerfile gitlab-ci

这就是我做一些 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 .

但是每次测试都必须将软件包安装到 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

那我做

$ docker build -t linter-testing:latest .

还有这个 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 .

但它失败并出现此错误:

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

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

最佳答案

您需要编辑 config.toml 文件,该文件位于运行器机器上的 /etc/gitlab-runner 中,使用以下内容

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

查看相关问题 here .

关于docker - Gitlab CI/Docker : Use custom image for job,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43481618/

相关文章:

r - Ubuntu 18.4安装R语言3.5

Docker:来自守护进程的错误响应:没有这样的 id:

docker - 无法解析docker容器内的域名

django - 使用Nginx,Django和Docker服务静态文件

Docker入口点权限被拒绝

linux - 运行者不健康,将被禁用

docker - 如何将A类IP子网添加到docker0网桥

http - 通过 HTTP 获取私有(private) GitLab 仓库

git - Gerrit + GitLab 的 CI

docker - PHP 服务构建 Docker 失败