Docker Community Forums

Share and learn in the Docker community.

Mounting external shares into a container persistently

I have been trying to get external shares from a NAS (e.g. //NASDrive/share) mounted within a container. This is the easy bit. The problem that I have is that if I stop the container or restart the docker host the shares aren’t getting remounted automatically. I must connect to the container and remount them manually.

I know that the normal way to mount persistently within Ubuntu would be to add it to /etc/fstab. But I also know that this doesn’t work within a container.

What I would like to find out is how I can get shares mounted into a container that are persistent and will always remount when restarted. To make this easier for myself I have added it to /etc/fstab anyway and I connect to the container after a restart and run “mount -a”.

Any help would be appreciated as nothing I find online really solves this for me.

this should help:

The locale driver support cifs mounts as well. The syntax is lightly different though.

Thank you, I will give it a go.