While it is recommended to work with the CSCS internal provided registry due to fastest network connection, it is also possible to work with third party registries like dockerhub.com or quay.io. When you work with third party registries, then you have to provide login credentials for the CI jobs.

There are two possible ways to push images to third party registries (it is assumed that you have stored the variable DOCKERHUB_ACCESS_TOKEN at the CI setup page):

The first approach will push both to the CSCS registry and additionally to the third party registry at dockerhub.com

my_job:
  extends: .container-builder-cscs-zen2
  stage: my_stage
  variables:
    DOCKERFILE: path/to/Dockerfile
    PERSIST_IMAGE_NAME: $CSCS_REGISTRY_PATH/my_image:${CI_COMMIT_SHORT_SHA}
    SECONDARY_IMAGE_NAME: docker.io/your_dockerhub_username/my_image:${CI_COMMIT_SHORT_SHA}
    SECONDARY_IMAGE_USERNAME: your_dockerhub_username
    SECONDARY_IMAGE_PASSWORD: $DOCKERHUB_ACCESS_TOKEN


The second approach will only push to a third party registry at dockerhub.com:

my_job:
  extends: .container-builder-cscs-zen2
  stage: my_stage
  variables:
    DOCKERFILE: path/to/Dockerfile
    PERSIST_IMAGE_NAME: docker.io/your_dockerhub_username/my_image:${CI_COMMIT_SHORT_SHA}
    CUSTOM_REGISTRY_USERNAME: your_dockerhub_username
    CUSTOM_REGISTRY_PASSWORD: $DOCKERHUB_ACCESS_TOKEN