I’m using the following command in my GitLab pipeline but it always returns that it cannot authenticate.
I tried it on my local CLI but still fails. I’m using the following command.
docker login -u <Access Token Name> -p <Token Value> registry.digitalocean.com

I generated a new access token to see if it works but still nothing.

Any suggestions?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi there,

Do you get an error during the docker login command or do you get the error when you try to push/pull the images?

Usually, once you’ve authenticated, when pushing or pulling images, you need to specify the repository as well:

docker tag <my-image> registry.digitalocean.com/<my-registry>/<my-image>
docker push registry.digitalocean.com/<my-registry>/<my-image>

Regards,
Bobby

  • My problem is when doing docker login
    I think that my problem is with the -u tag because I’m not sure of the username value that I’m using. I’m generating the personal access token in the API section and using the name of the token as the -u value, also tried my regular email with the account. But I’m sure that’s not the way.

    If I tried using doctl I can log in to the registry from my local with the access token, which is the best solution. But in this case I require using docker login because it is part of a stage on a GitLab pipeline and there I cannot use doctl (or at least I haven’t found a way to do it).

    Any recommendations on the proper way to put the value for -u in the docker login command or any other suggestion?

  • Found the solution… I cannot believe I’ve been so dumb…

    The proper way to login to DigitalOcean’s registry is by using the -u value with the same token you use for the -p value…

    Also, I managed to login to DO’s registry using doctl in my GitLab stage using an Alpine package that is in the Edge repo.

    This is how my solution look’s like:

    publish-do:
      image: docker:latest
      stage: publish
      variables:
        TAG_LATEST: $CI_DIGITAL_OCEAN_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
        TAG_COMMIT: $CI_DIGITAL_OCEAN_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
      services:
        - docker:dind
      before_script:
        - apk update
        - apk upgrade
        - apk add doctl --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
      script:
        - doctl auth init --access-token $DIGITALOCEAN_ACCESS_TOKEN
        - doctl registry login
        - docker build -t $TAG_COMMIT -t $TAG_LATEST .
        - docker push $TAG_LATEST
    

    I had to specify that apk should fetch the package from the specific edge repository where the package is.

    I know is not production-ready but for what I’m using DigitalOCean’s registry, it is enough.

Submit an Answer