running and sharing a host folder from a container using docker-py

669 views Asked by At

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 !

1

There are 1 answers

1
Rambler On BEST ANSWER

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'}
}
)