'Docker GitLab pipeline returns invalid argument for "-t, --tag" flag: invalid reference format
I'm receiving the below error message in my GitLab pipeline when attempting to create a docker image and then push it up to my docker hub account. It seems to be a syntax issue and I have tried a few combinations but cannot get it to work.
Can anybody help? Thanks.
Login Succeeded
$ docker build -f Dockerfile --tag ${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA} .
invalid argument "https://gitlab.com/madrandom/docker/-/blob/main/ubuntu_packer:bc9d2a3c" for "-t, --tag" flag: invalid reference format
See 'docker build --help'.
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 125
the .gitlab-ci.yml file is configured as below:
stages:
- build
variables:
IMAGE_NAME: https://gitlab.com/madrandom/docker/-/blob/main/ubuntu_packer
build:
stage: build
image: docker:18-git
services:
- docker:18-dind
script:
- echo "$DOCKER_HUB_PASS" | docker login --username=${DOCKER_HUB_USER} --password-stdin
- docker build -f Dockerfile --tag ${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA} .
- docker push ${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}
Solution 1:[1]
The IMAGE_NAME variable is not correct for naming docker images. Below are the issues:
https:-->:as it is special character for the tagshttps://-->//again, these special characters for docker image name. you can't use//together. There has to be something in the middle likehttps/a/b/-/-->-you cannot have only-within/. you need to have some words along with it or either remove it.
If you do this, this should solve the issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
