Home > Mobile >  Invalid argument for "-t --tag" flag: invalid reference format
Invalid argument for "-t --tag" flag: invalid reference format

Time:02-15

I'm trying to build the docker image using this script:

release.sh

#!/bin/sh

set -e

export ENV="prod"
export REGISTRY_HOST="registry.seesunit.kr"
export IMAGE_PREFIX="$ENV-scim"
export IMAGE_TARGET="web"
export IMAGE_NAME="$REGISTRY_HOST/$IMAGE_PREFIX-$IMAGE_TARGET"
export DOCKER_ROOT="/home/dev-admin/docker"
export DOCKER_PATH="$DOCKER_ROOT/$IMAGE_PREFIX/$ENV-$IMAGE_TARGET"

#echo "CONTAINER > "
#docker container ls | grep $IMAGE_NAME #| grep -Eo "^[^ ] "
echo "IMAGES > "
docker images | grep $IMAGE_NAME #| grep -Eo "^[^ ] "

echo "Input IMAGE_TAG :"
read IMAGE_TAG

echo "TAG=$IMAGE_TAG" > $DOCKER_PATH/.env
echo "IMAGE_NAME=$IMAGE_NAME" >> $DOCKER_PATH/.env
echo "TAG=$IMAGE_TAG" > .env
echo "IMAGE_NAME=$IMAGE_NAME" >> .env

docker-compose -f $DOCKER_PATH/docker-compose.yml down

#echo "Q4. DOCKER_ID_USER?"
#read DOCKER_ID_USER
docker rmi -f $IMAGE_NAME:$IMAGE_TAG

docker build -f ./tools/$ENV.Dockerfile -t $IMAGE_NAME:$IMAGE_TAG .

#docker tag $IMAGE_NAME:$IMAGE_TAG $DOCKER_ID_USER/$IMAGE_NAME:$IMAGE_TAG
#docker push $DOCKER_ID_USER/$IMAGE_NAME:$IMAGE_TAG

#docker push $IMAGE_NAME:$IMAGE_TAG

docker-compose -f $DOCKER_PATH/docker-compose.yml up -d

Current containers

CONTAINER ID   IMAGE                                     COMMAND                  CREATED       STATUS       PORTS                                     NAMES
dad647696802   registry.seesunit.kr/prod-scim-web:v_db   "nginx -g 'daemon of…"   2 weeks ago   Up 2 weeks   0.0.0.0:30080->80/tcp, :::30080->80/tcp   prod-web_prod-web_1

When I tried to run docker build from the command line:

docker build -f ./tools/$ENV.Dockerfile -t prod-web_prod-web_1:registry.seesunit.kr/prod-scim-web:v_db .

I got an error like this:

invalid argument "prod-web_prod-web_1:registry.seesunit.kr/prod-scim-web:v_db" for "-t, --tag" flag: invalid reference format
See 'docker build --help'.

I'm running on Windows.

CodePudding user response:

-t prod-web_prod-web_1:registry.seesunit.kr/prod-scim-web:v_db
                      ^                                  ^
                      |                                  |

You have two colons (:) in your name:tag argument.

Docker thinks your image tag is registry.seesunit.kr/prod-scim-web:v_db which contains a colon, and from https://docs.docker.com/engine/reference/commandline/tag/:

A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. A tag name may not start with a period or a dash and may contain a maximum of 128 characters.

CodePudding user response:

As it says, your image name/tag is invalid.

Image names are slash-separated. You can prefix with a registry address including optional port number.

your prod-web_prod-web_1:registry.seesunit.kr/prod-scim-web:v_db has too many colons. My guess is that the first bit is there by error and what you want is registry.seesunit.kr/prod-scim-web:v_db, i.e. your build command should be

docker build -f ./tools/$ENV.Dockerfile -t registry.seesunit.kr/prod-scim-web:v_db .
  • Related