67.0k views
4 votes
How to bind readonly mounts while creating a service?

A) --readonly
B) --read-only
C) --bind-read-only
D) --mount=readonly

User Rashmi
by
7.9k points

1 Answer

7 votes

Final answer:

The correct option to create a read-only mount while defining a service is using the --read-only flag. If you want to make specific mounts read-only, the --mount flag should be used with 'readonly' specified in the mount definition.

Step-by-step explanation:

When creating a service, particularly in the context of containerization technologies like Docker, you may want to use a read-only mount to ensure that the data within the mounted volume or file cannot be changed by the processes running in the container. The correct option to create a read-only mount while defining a service is --read-only (Option B). It is important to note that this flag makes the whole container file system read-only. However, if you want to make specific mounts read-only, you should use mounts in combination with the --mount flag, specifying readonly as an option in the mount definition (e.g., --mount type=bind,source=/path/on/host,target=/path/in/container,readonly) instead of a global read-only setting for the container.

User Dongnhan
by
9.1k points