docker / docker/docker-py

Cant pass input variable from keyboard to docker/utils/utils.py

Open
#2,405 3 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

Hi guys, I'm pretty new to the docker api, so basically Im trying to use docker.Client with a python script using input ip as variable, Im getting this error. any Ideas?.

script ->
import docker
import re
import sys
ip = sys.argv[1]
cli = docker.Client(base_url="'http://"+ (ip) +":4243'")

usage : >
python3 docker-jen.py 192.168.1.122

Traceback (most recent call last):
File "docker-jen.py", line 10, in
cli = docker.Client(base_url="'http://"+ (ip) +":4243'")
File "/usr/local/lib/python3.5/dist-packages/docker/client.py", line 59, in init
base_url, constants.IS_WINDOWS_PLATFORM, tls=bool(tls)
File "/usr/local/lib/python3.5/dist-packages/docker/utils/utils.py", line 415, in parse_host
"Invalid bind address protocol: {0}".format(addr)
docker.errors.DockerException: Invalid bind address protocol: 'http://192.168.1.122:4243'

According to utils.py line 415 the error should be generated if no protocol is used, but in the bold line above I can see it passing thru. what am I doing wrong? if I perform that script using an static ip from the code it works like a charm.

many thanks in advance and sorry if this is a silly question.

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 provided script and the docker.Client call, then inspect docker/utils/utils.py around line 415 and reproduce the command with the supplied IP argument. Determine whether the reported error is caused by the constructed base_url or by the library; done means a verified explanation or a narrowly scoped, reproducible library fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.