Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 350
user3142695 Avatar asked Apr 18 '17 20:04

user3142695


1 Answers

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.

like image 110
Jawad Avatar answered Sep 28 '22 04:09

Jawad