Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best Practice: Read Only Mounts in Swarm #2813

Open
shinybrar opened this issue Apr 10, 2021 · 1 comment
Open

Best Practice: Read Only Mounts in Swarm #2813

shinybrar opened this issue Apr 10, 2021 · 1 comment

Comments

@shinybrar
Copy link

shinybrar commented Apr 10, 2021

Current Setup

Right now, my current setup looks something like this,

driver = DriverConfig(
    name=None,
    options={
        "o": "nfsvers=4.0,noatime,nodiratime,soft,addr=x.x.x.x,ro", #read-only
        "device": ":/path/to/data",
        "type": "nfs",
       },
)
mount = Mount(
    type="volume",
    source=None,
    target="/data",
    driver_config=driver,
)
container = ContainerSpec(
    image=image_name,
    command=command,
    args=arguments,
    env=environment,
    mounts=[mount]
    ...
)
task = TaskTemplate(
    container_spec=container,
    restart_policy=RestartPolicy("none"),
    placement=placement,
    resources=resources,
    ...
)
service = client.create_service(
    task,
    name=name,
    networks=["swarm-attachable-network"] ,
    endpoint_spec=EndpointSpec(mode="vip"),
)

Question

Alternatively, there is also an option to specify a mount to be read-only via,

mount = Mount(
    type="volume",
    source=None,
    target="/data",
    driver_config=driver,
    read_only=True, # read-only
    ...
)

This fails however with the following error,

"invalid mount config for type "volume": must not set readonly mode when using anonymous volumes"

In this scenario what is the best practice to deploy NFS mounts?

  • Can source be any uuid identifier?
  • Does source have to be a pre-defined volume?
  • Do you have to make host specific volume on each swarm node?
  • Can you centrally manage volumes?
@tknerr
Copy link

tknerr commented Jun 19, 2024

See also related issue moby/moby#45297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants