docker / docker/docker-py

Remote Docker Registry Auth

Open
#3,244 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

`
class DockerDeployment:

def __init__(self, ip) -> None:
    self.ip = ip
    self.client = DockerClient(f"ssh://{_SSH_USER}@{ip}:22", use_ssh_client=True)
    ssh_adapter = KeyFileSSHAdapter(f"ssh://{_SSH_USER}@{ip}:22")
    self.client.api.mount('http+docker://ssh', ssh_adapter)

def _get_next_port(self):
    containers : list[Container] = self.client.containers.list()
    highest_public_port = 1000
    for container in containers:
        for port in container.ports:
            public_port = int(container.ports[port][0]["HostPort"])
            if public_port > highest_public_port: highest_public_port = public_port

    return highest_public_port + 1

def create_deployment(self, address, repo, image, version, env={}) -> Container:
    port = self._get_next_port()

    default_env = {
        "ADVERTISED_ADDRESS": f"{self.ip}:{port}",
        "LOCAL_ADDRESS": "0.0.0.0:7080",
        "REGISTRY": f"{self.ip}:8500"
    }

    image_url = f"{address}/{repo}/{image}"
    container : Container = self.client.containers.run(
        image=f"{image_url}:{version}",
        ports={"7080": port, "7081": port+1},
        environment=env|default_env,
        auto_remove=True,
        detach=True
    )
    return container

`

So I am using this code to deploy an image onto a remote machine. However, my current machine should not require authentication for the repository since this should be required by the machine deploying the image.

On machine running the deployment I have run docker logout.
On remote machine I have run docker login address to ensure the remote machine has the credentials to pull the image.
However I get the following error:

500 Server Error for http+docker://ssh/v1.45/images/create?tag=0.1.0&fromImage=redacted: Internal Server Error ("Head "redacted/manifests/0.1.0": unknown: Authentication is required")

Is this a limitation of the registry I am using or a limitation of the docker python library/docker? For context, I am using JFrog Artifactory as a private repository.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the DockerDeployment DockerClient SSH setup and the containers.run call that triggers the image pull. Reproduce the Artifactory case with the local client logged out and the remote machine logged in, then trace which daemon receives the pull request and how credentials are supplied. Done means identifying whether this is a docker-py limitation, a registry limitation, or an authentication configuration issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
devops, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.