Docker image name validation in .gitlab-ci.yml

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

Currently, using image: "docker pull my-image-name:tag" in the gitlab-cy.yml file does not fail validation, but it fails to start e.g. kubernetes runners (they fail to start up).

Steps to reproduce

  1. configure to run your project on a kubernetes-runner.
    Note: The docker fails at runtime too, but fails after 3 errors starting the containers, while kubernetes fails only after the job timeout.
  2. use the following .gitlab-ci.yml:
    # .gitlab-ci.yml
    test-job:
      image: "docker pull debian:stretch"
      script:
      - echo "works"
  3. Observe that the runner times out.
    If checked in kubernetes, you'll see that the container is waiting with the InvalidImageName reason. Note that InvalidImageName is not solvable by pushing a tag, as that would be an ErrImagePull - the image could not be pulled. This error is that no image can exist with that name, in current systems.

Example Project

https://gitlab.com/matthias.vandemeent/test-ci-results/-/tree/test-ci-yaml

See https://gitlab.com/matthias.vandemeent/test-ci-results/-/jobs/587311197 for docker runner output; there is sadly no public kubernetes runner to work off of.

What is the current bug behavior?

The gitlab-ci.yml validation does not validate the docker image, or does not fail fast in the kubernetes runner case. The docker tag name format is (afaik) well-documented, and therefore a validator should not be too difficult to include.

What is the expected correct behavior?

Either the job fails on startup, or the ci yaml fails to validate and no pipeline is run at all.

Relevant logs and/or screenshots

image

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Possible fixes

As above: Validate the image field in the job spec either at the runner or in the application.

Edited by 🤖 GitLab Bot 🤖