Docker image push issue (no basic auth credentials)

Hi everyone, I am facing some weird issue in regards to pushing docker images to the registry. The issue occurs randomly during CI builds. For context, my team’s tech stack consists of:

  1. Docker version 18.09.6, build 481bc77156
  2. Private SonaType Nexus artifact registry (Sonatype Nexus Repository - Binary & Artifact Management | Sonatype) running in our own datacenter based for hosting different builds including docker imges.
  3. TeamCity 2023.11.4 build 147586 (TeamCity: the Hassle-Free CI/CD Tool by JetBrains) on premise CI/CD automation tool.
  4. Red Hat Enterprise Linux Server 7.6 (Linux master 3.10.0-957.12.1.el7.x86_64) OS based agent nodes (where TeamCity CI/CD pipelines run.
  5. Docker Compose version v2.17.2

The issue is that during TeamCity builds, Docker randomly throws no basic auth credentials provided error even though Docker successfully logins into the registry at the start.

10:54:25 Step 1/7: Docker login (Command Line)
10:54:25   Starting: /u/bin/Teamcity/buildAgent/temp/agentTmp/custom_script5474679110587913065
10:54:25   in directory: /u/bin/Teamcity/buildAgent/work/cd0a5efd33c51956
10:54:25   WARNING! Using --password via the CLI is insecure. Use --password-stdin.
10:54:25   WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
10:54:25   Configure a credential helper to remove this warning. See
10:54:25   Login Succeeded
10:54:25   https://docs.docker.com/engine/reference/commandline/login/#credentials-store
10:54:25    
10:54:25   WARNING! Using --password via the CLI is insecure. Use --password-stdin.
10:54:27   WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
10:54:27   Configure a credential helper to remove this warning. See
10:54:27   https://docs.docker.com/engine/reference/commandline/login/#credentials-store
10:54:27   Login Succeeded
10:54:27   
10:54:27   Process exited with code 0
11:11:38   Starting: /bin/sh -c docker push  eng-ai-docker.xyz.com/aiadminportalbackend:111a742b696bbce32f72f08d9cc000fd355042a6
11:11:38   in directory: /u/bin/Teamcity/buildAgent/work/cd0a5efd33c51956
11:11:38   The push refers to repository [eng-ai-docker.xyz.com/aiadminportalbackend]
11:11:38   a95dc002baac: Preparing
11:11:38   7f7daff96204: Preparing
11:11:38   fbd27198d168: Preparing
11:11:38   24ac270f33bb: Preparing
11:11:38   2dfbb64d4c56: Preparing
11:11:38   Unable to push eng-ai-docker.xyz.com/aiadminportalbackend:latest to remote repository:
  Unauthorized
11:11:38   no basic auth credentials

If I re-run the pipeline manually, it works just fine. It even works correctly during most of the automatic builds.Another thing that i’ve noticed is that when docker push fails. it shows the image with latest tag even though the custom image tag is already specified.Does someone have any idea why it is happening or has at least a partial idea.?

That is a very old version, more then 5 years old and could have many compatibility issues with recent registries or images.

This issue doesn’t appear in 99% of the builds. In some cases, it does. Upon rerunning the steps manually, it disappears.

I understand, but old Docker versions can have unexpected behavior, can be unstable. I can’t explain the error, but the old version is definitely something you should avoid.