Docker.io registry login within gitlab-ci?

Hi,

I’m trying to push my build after passing every test into the registry of docker.io.
But I’m really unable to do this in my release task.

My steps are the following:

  • (before_script) login into gitlab registry
  • pull my testing image
  • retag it to release
  • login into docker.io registry
  • push it

The variable DOCKER_USER and DOCKER_PASSWORD are defined in gitlab-ci variable configuration and are protected.

[...]
before_script:
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com

release:sshoney:
  stage: release
  script:
    - docker pull $TESTING_CI_IMAGE
    - docker tag $TESTING_CI_IMAGE $RELEASE_IMAGE
    - docker login --username $DOCKER_USER --password $DOCKER_PASSWORD docker.io
    - docker push $RELEASE_IMAGE
$ docker login --username $DOCKER_USER --password $DOCKER_PASSWORD docker.io
Error: Cannot perform an interactive login from a non TTY device

I tried a lot of stuff. Also using --password-stdin together with --username. None of them worked for me.
Has anyone done this task already and knows how to do this?
Also if there is a better way I’m open to know! :slight_smile:

Cheers

EDIT:
I got it. Reading how protected variables are working solved it for me. I need to perform this action inside a protected branch since I also protected my variables.

2 Likes

Welcome to the GitLab forum! Thanks for the post and extra kudos for posting the solution after you figured it out. That’s the spirit :slight_smile:

1 Like