Gitlab CI / Docker: Use custom image for job

user3142695

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

Jawad

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Gitlab CI - Use docker image offline

GitLab CI invalid argument on job for Docker build

How to keep docker image build during job across two stages with Gitlab CI?

running job as a Docker Container in gitlab CI - Docker wormhole pattern

Gitlab-ci docker inside java image

Gitlab-ci image with docker and java/gradle

gitlab CI create docker image and push to AWS

Gitlab CI/CD not picking up docker image

Gitlab CI Pipeline job

How to use a custom windows docker container on gitlab-ci shared runner

Install Docker in container for use by GitLab CI build

Gitlab: How to pass CI_JOB_TOKEN to Docker to be used with maven?

xargs docker stop needs at least 1 argument in GitLab CI job

use image from gitlab Registry in CI

How use ssh proxy to run deploy job in gitlab ci?

GitLab CI/CD Docker-In-Docker Failing with Custom DIND Service

Using a private Docker Image from Gitlab Registry as the base image for CI

How to execute a command from a docker image in a gitlab job?

gitlab-ci.yml ignoring docker image in private runners

Running Docker image of Postman from Gitlab CI pipeline

Env vars lost when building docker image from Gitlab CI

Gitlab CI how to run tests before building docker image

Building a Docker image for a Node.js app in GitLab CI

gitlab-ci.yml: how to create a docker image using dind

Failing to compile golang project in gitlab-ci using docker image

Can't Access Private MySQL Docker Image From Gitlab CI

Building and pushing Spring Boot maven plugin docker image in Gitlab CI

Gitlab CI tries to find 'of:latest' image from public docker hub

Pushing Docker image from gitlab-ci to Azure Container Registry