2

I want to run a container using the python docker with a persistent shared folder. The command line to do so is as follow :

docker run --rm -ti -v /home/docker:/container_shared_folder ubuntu:14.04 bash -c my_command

can you please help me to realize that using docker-py ?

Regards !

igal
  • 646
  • 7
  • 17
Mounirsky
  • 117
  • 7

1 Answers1

2

Can you try specifying volumes in the following manner :

cmd_stdout = client.containers.run(
my_container, 
my_command, 
remove=True, 
volumes= 
{'/home/user/location1': {'bind': '/mnt/vol1', 'mode': 'rw'},
 '/home/user/location2': {'bind': '/mnt/vol2', 'mode': 'rw'}
}
)
Rambler
  • 4,994
  • 2
  • 20
  • 27
  • I'm using this manner : `import docker client = docker.from_env() cmd_stdout = client.containers.run(my_container, my_command, remove=True, volumes= ???????)` Can you please be more clear about : cli ? vol1 ? vol2... Regards. – Mounirsky Dec 20 '16 at 08:49