0

i was studying docker-py library, using create_container function in that library we can easily create multiple containers, but the thing i want to do here is to pass multiple parameters in this function, In bash the command i am running for creatiion of containers is like this;

docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name hello1i -v /root/one.txt:/root/one.txt -e VARIABLE='hello-world' -d myimage:hello /bin/bash start.sh

now what i want is to do execute this command using docker-py library , using create_container function, but i am not clear how to pass these ("--cap-ad", "device", "-e") parameters in it ? Can anybody help me ?

Saad
  • 916
  • 1
  • 15
  • 28
  • Have you tried reading [the documentation](https://docker-py.readthedocs.io/en/stable/containers.html)? It seems to clearly answer your question. – larsks Sep 13 '17 at 12:51
  • there are multiple arguments that are not working fine ! like cap_add="" and devices="" `TypeError: create_container() got an unexpected keyword argument 'devices'` – Saad Sep 13 '17 at 13:40
  • @larsks i want to specifically add the parameter devices="/dev/net/tun", as i am setting up an openvpn client from my docker container, and without setting the devices parameter, i am getting this error `ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory` – Saad Sep 13 '17 at 14:02
  • Well, looking at the docs, there is no `create_container` method, so there seems to be some mismatch between these docs are what you're using. It looks as if there are a couple of python modules; try `pip install docker` instead of `pip install docker-py`. – larsks Sep 13 '17 at 14:06
  • ...but if `/dev/net/tun` does not exist in your container, that seems like a different question. – larsks Sep 13 '17 at 14:07
  • it is working fine, when i am passing the parameter "--device" form linux shell, but i want to use this parameter in docker-py "create_container" function. its not working and i can't understand why, where as documentation simply says; `devices (list) – Expose host devices to the container, as a list of strings in the form ::` – Saad Sep 13 '17 at 14:20

0 Answers0