Hi all, noticed that following did not work becau...
# ask-community
a
Hi all, noticed that following did not work because it creates capitalised keys and adds some additional keywords like networkmode
Copy code
client = docker.from_env()
host_config = client.api.create_host_config(binds=[
    '/psql/data/:/data'])
print(host_config)

container_id = CreateContainer(command="cat /data/test",
                      host_config=host_config)
ended up doing
Copy code
container_id = CreateContainer(command="cat /data/test", host_config={'binds': ['/psql/data/:/data']}
which works I think that part of documentation needs to update.
👍 1
upvote 1
k
Hey @Antti Tupamäki, you’re not the only one who ran into this for sure and some improvement might be needed. What are your thoughts are to improve this? The docstring of
host_config
already says it should be a dict.
a
Now at least how I did read that is you need to call create_host_config which retuns dict, not use those parameters in dict. I would underline somehow that you need to create dict and use these https://docker-py.readthedocs.io/en/stable/api.html#docker.api.container.ContainerApiMixin.create_host_config
k
@Marvin open “CreateContainer host_config docs could be clearer”