Alp
Alp

Reputation: 29739

Docker volume which is read-only on the host

I know that i am able to specify a volume which is read-only on the container:

docker run -v /path/on/host:/path/on/container:ro my/image

But I need the opposite behavior: A folder that is read-write on the container and read-only on the host. Is that possible?

Background: I want to tell my IDE the path of the python executable which is in a virtualenv in a docker container.

Upvotes: 1

Views: 2512

Answers (1)

gabrtv
gabrtv

Reputation: 3588

I don't believe this is possible using bind-mounts alone. Instead I would recommend using filesystem permissions on the host.

  1. Bind-mount the volume with read-write permissions (so the container can write to it)
  2. Use filesystem permissions on the host to restrict access from specific UID/GIDs

Another option is having the container export the path to the network using NFS/SMB/etc and have that mounted by the host -- though this is trickier.

Upvotes: 1

Related Questions