I'm trying OS env variables to be used in python code. Below is example.
Env Variable
export DOCKER_HOST=10.0.0.5
export PORT=1002
Python code
import os
import docker
host = os.environ['DOCKER_HOST']
port = os.environ['PORT']
client = docker.APIClient(base_url='tcp://host:port')
It is supposed to inject the variables of host and port but its not working. I tried to add .format which is helpless
Error
raceback (most recent call last):
File "./update.py", line 24, in
client = docker.APIClient(base_url="tcp://docker_host:docker_port")
File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 109, in __init__
base_url, IS_WINDOWS_PLATFORM, tls=bool(tls)
File "/usr/local/lib/python2.7/dist-packages/docker/utils/utils.py", line 363, in parse_host
"Invalid port: {0}".format(addr)
docker.errors.DockerException: Invalid port: docker_host:docker_port