i am trying to build multiple docker images and push them to my gitlab container registry.
This works just fine, when i build and push them like this:
stages:
- build
docker-build-template:
# Use the official docker image.
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
variables:
OS_IDENTIFIER: "ubuntu-1604"
script:
- cp docker/base/ubuntu-1604.dockerfile Dockerfile
- docker build --pull -t "${OS_IDENTIFIER}-base${tag}" .
- echo $CI_REGISTRY_IMAGE
- docker push $CI_REGISTRY_IMAGE
But when I try changing the docker push command according to Gitlabs Container Registry Naming Convention the pipeline fails every time, as it tries to access a registry, which does not exist. Here is a list of commands i have tried and all failed.
- docker push ${CI_REGISTRY_IMAGE}/${OS_IDENTIFIER}-base${tag}
- docker push ${CI_REGISTRY}/$[CI_PROJECT_ROOT_NAMESPACE}/${CI_PROJECT_NAME}
- docker push ${CI_REGISTRY}/$[CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}
- docker push ${CI_REGISTRY}/<my-group>/<my-project>/<image>:latest
- docker push <registry.example.com>/<mynamespace>/<myproject>/<image>:latest
All of the mentioned above (I've tried many more combinations) yield this error:
$ docker push <one-of-the-above>:latest
An image does not exist locally with the tag: <one-of-the-above>
The push refers to repository [<one-of-the-above>]
The push command seems to refer only to a entire repository and not as I expected when using the naming convention. How do I solve this issue? What am I doing wrong?
Thank you in advance