Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote Docker Registry Auth #3244

Open
OOOllie opened this issue Apr 4, 2024 · 0 comments
Open

Remote Docker Registry Auth #3244

OOOllie opened this issue Apr 4, 2024 · 0 comments

Comments

@OOOllie
Copy link

OOOllie commented Apr 4, 2024

`
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant