docker / docker/docker-py

docker-py does not return the host-address when using ssh transport

Open
#2,254 0 comments 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

I checked the way docker-py api works when using local docker or remote docker (swarm or not) and I failed to find where it would return the host-address of the running container.

Returning "0.0.0.0" has zero value to the application using docker-py because that 0.0.0.0 may not be application localhost if DOCKER_HOST variable points to a remote machine.

I asked this question on Slack and stackoverflow but without any answers so far.

It seems that now the docker-py application would be forced to parse the DOCKER_HOST variable itself, look if it can extract a hostname out of it and use it, with a fallback to localhost. This seems as a very bad practice that is likely to break in many scenarios.

The IP or hostname of the machine running the container should be returned by docker-api itself.

I tried to get some information out of docker.info() but Name is unreliable as on one machine it happened to be the right hostname but on a machost it returned the name of the linuxvm running docker, clearly not something that was addresable/accesible. There was also the ['Swarm'].['NodeAddr'] which was looking ok in one case but it was empty in others.

I think that the application itself should not be aware of DOCKER_HOST and that the host-address should be returned/exposed by the docker-py api.

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 by tracing the docker-py API path for SSH transport and compare it with the docker.info() and Swarm NodeAddr values mentioned in the issue; also inspect how DOCKER_HOST is currently interpreted. Done means the API exposes a reliably addressable host address for containers reached through SSH transport without requiring applications to parse DOCKER_HOST, with behavior defined for the described cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.