4
docker -v host_dir:container_dir ...

I know from the above, when we're running scripts inside the container, writing to container_dir copies the written files to host_dir. But are all host_dir files also synced into the container?

user3180
  • 1,369
  • 1
  • 21
  • 38
  • 6
    Actually, the host directory is mounted in the container under the container directory name. So it is the same directory, nothing is copied or synced. – Henry Jan 14 '19 at 04:46

1 Answers1

-1

By default it is mounted as rw (read-write mode) , Howver in case you need a readonly volume it is possible.

docker run -v volume-name:/path/in/container:ro my/image

In Docker-Compose

version: "3"
services:
  redis:
    image: redis:alpine
    read_only: true

Take reference : Docker, mount volumes as readonly

fly2matrix
  • 2,351
  • 12
  • 13