docker login failed with status: 503 Service Unavailable

I have a Bitbucket pipeline where I try to connect to a private docker registry. Here is a command:

echo "$DOCKER_REGISTRY_PASSWORD" | docker login $DOCKER_REGISTRY_URI --username $DOCKER_REGISTRY_USER --password-stdin

which throws an error:

Error response from daemon: login attempt to $DOCKER_REGISTRY_URI/v2/
failed with status: 503 Service Unavailable

But this command works on my local PC (I get "Login Succeeded" message).
Also I see 200 status code in logs after bitbucket run command above and throws 503)

How to solve this problem?

p.s.

  1. I haven’t set whitelist IPs, firewall
  2. I user caddy to as a proxy with the following configuration:
registry.example.com {
  log {
    output stdout
  }

  tls /root/certs/certificate.pem /root/certs/key.pem

  basicauth {
    user <hidden>
  }

  encode gzip

  header {
    Referrer-Policy "same-origin"
    Strict-Transport-Security "max-age=15768000;"
    X-Content-Type-Options "nosniff"
    X-Frame-Options "DENY"
    X-XSS-Protection "1; mode=block"
    -Server
  }

  reverse_proxy /v2/* registry:5000 {
    header_up Distribution-Api-Version "registry/2.0"
  }
}

Source: Docker Questions

LEAVE A COMMENT