6

I've created a repo in gitlab for a Dockerfile. In the .gitlab-ci.yml i defined two stages: build and push to the registry.

This is the .gitlab-ci.yml file:

image: docker

stages:
    - build
    - push

build:
    stage: build
    script:
      - docker build --no-cache -t ${DOCKER_REGISTRY}/debian9-cunit .

push:
    stage: push
    script:
      - docker push ${DOCKER_REGISTRY}/debian9-cunit

When I run the pipeline, the build stage fails saying:

invalid argument "/debian9-cunit" for "-t, --tag" flag: invalid reference format

The same exact code (with only a different name after "/debian9-") works with no problem in another repo of a collegue. What can be the problem?

8
  • 2
    Seems the ${DOCKER_REGISTRY} variable is not replaced, perhaps the pipeline is looking into system variables. could you try to add double quotes in the script section? Commented Nov 6, 2018 at 13:32
  • I tried both "${DOCKER_REGISTRY}/debian9-cunit" and "${DOCKER_REGISTRY}"/debian9-cunit but the result is the same Commented Nov 6, 2018 at 13:39
  • Try replacing ${DOCKER_REGISTRY} with an actual existing repository. I agree with @M.Falzone, seems like that variable isn't set, and Docker is yelling because you can't start your tag with a slash. Commented Nov 6, 2018 at 13:58
  • is it possible that DOCKER_REGISTRY isn't setted up? btw seems you want to use the gitlab.com registry, in that case, try with "docker build --no-cache -t ${CI_REGISTRY}/${CI_PROJECT_PATH}/debian-9-cunit ." Commented Nov 6, 2018 at 13:59
  • If I replace with ${CI_REGISTRY}/${CI_PROJECT_PATH}/debian-9-cunit I get: "invalid argument "/federico/dk-debian9-cunit/debian9-cunit" for "-t, --tag" flag: invalid reference format" Commented Nov 6, 2018 at 14:04

2 Answers 2

7

If anyone is having this issue in combination with Heroku-based applications (e.g. in Gitlab AutoDevOps) you might need to activate the GitLab container registry on your GitLab installation and in your project.

Sign up to request clarification or add additional context in comments.

Comments

1

Problem solved: I didn't have a GitLab runner on my personal company profile. The other project was of a group that has a shared runner.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.