Sam Hooke

Docker build invalid reference format

TL;DR: If “Container Registry” is not enabled for your project, docker build will give a cryptic error such as: invalid argument ":master" for "-t, --tag" flag: invalid reference format

Situation: Created a new project in GitLab, setting up Docker-in-Docker CI to push containers to the GitLab “Container Registry”.

Problem: Kept getting the following error:

$ docker build --pull --no-cache -t $IMAGE_TAG .
invalid argument ":master" for "-t, --tag" flag: invalid reference format
See 'docker build --help'.

Solution: Enable “Container Registry” for the project, by going to Settings → General → Visibility, project features, permissions → Container Registry.

Note: This assumes that “Container Registry” is enabled on your GitLab instance.

Further reading: