I want to mount NFS share for a Docker container.
I know it is possible since Docker 17.06, like described by ThiagoAlves in this answer.
docker run --mount \
"src=$NFS_VOL_NAME,dst=$NFS_LOCAL_MNT,volume-opt=device=:$NFS_SHARE,\"volume-opt=o=addr=$NFS_SERVER,$NFS_OPTS\",type=volume,volume-driver=local,volume-opt=type=nfs" \
busybox ls $NFS_LOCAL_MNT
But I want to do it using low-level Python API. There is a create_container function with a volumes
parameter but I only found examples for a classic mount (local_folder:container_folder). Ex:
container_id = client.api.create_container(
'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
host_config=client.api.create_host_config(binds={
'/home/user1/': {
'bind': '/mnt/vol2',
'mode': 'rw',
},
'/var/www': {
'bind': '/mnt/vol1',
'mode': 'ro',
}
})
)
How to call create_container or create_host_config to mount NFS shares?
Thanks!