python docker how to mount the directory from host to container
问题 can someone please share some examples of py apis showing how to mount the directories ? I tried like this but I dont see its working dockerClient = docker.from_env() dockerClient.containers.run('image', 'ls -ltr', volumes={os.getcwd(): {'bind': '/tmp/', 'mode': 'rw'}}) 回答1: By getting the container object Change your code according to the following: import os import docker client = docker.from_env() container = client.containers.run('ubuntu:latest', 'ls -ltr /tmp', volumes={os.getcwd(): {