简体   繁体   中英

Gitlab CI / Docker: Use custom image for job

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 .

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

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

Then I do

$ docker build -t linter-testing:latest .

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

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

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"

See related issue here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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