Docker push invalid format

I made this script to build and push images to a private docker registry. (The registry works with intellij pushing images for other project)

The docker push command continually keeps returning “invalid reference format” and I cannot figure out why.

Here is the script:

#!/bin/bash
set -x
set -v

REGISTRY_URL=https://registry.mydomain.com
REGISTRY_USERNAME=redacted
REGISTRY_PASSWORD=redacted

docker build -t backend:latest ./server
docker build -t frontend:latest ./client

docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $REGISTRY_URL

# Push the images to private registry
docker push $REGISTRY_URL/backend:latest
docker push $REGISTRY_URL/frontend:latest

# Log out from your private registry
docker logout $REGISTRY_URL

Output:

Login Succeeded
# Push the images to private registry
docker push $REGISTRY_URL/backend:latest
+ docker push https://registry.mydomain.com/backend:latest
invalid reference format
docker push $REGISTRY_URL/frontend:latest
+ docker push https://registry.mydomain.com/frontend:latest
invalid reference format

Could anyone explain why this is not working? I’ve searched away and nothing seems relevant.

[Solved] Need to tag first.

docker tag backend:latest $REGISTRY_URL/backend:latest