For those of us using Docker in an LXC container, and wish to mount one or more Windows Samba shares -- it seems this tutorial can be further simplified:
Assuming a fairly typical Docker container where UID and PID 1000 are being used, nothing needs to be done in the LXC container other than shutting it down.
As root on the PVE host, create the directories you'd like to mount to Samba shares. I have three to mount, so it looks like this:
These are the same names I used on the system I'm transferring these containers over from, to keep things easy.
Edit /etc/fstab similar to this (with appropriate modifications for your scenario), with your favorite editor -- I like WinSCP for this purpose (and for most PVE admin that can't be done from the WebUI):
Since Windows usernames and shares can have spaces in them -- note that I'm showing how to handle those above using \040 in place of the <space>. UID and PID 101000 on the host get translated to 1000 on the guest. mount -a will reload fstab, and make your shares live, which you can check from the command line or in WinSCP by navigating to your sub-directories under /mnt.
And lastly, the container config file, which in my case is /etc/pve/lxc/105.conf, needs to have lines added similar to these (adapted for your use-case of course):
Note that I'm using the same names for the container mount points as I am for the host mounts -- use different names if it suits, but keeping it consistent makes more sense to me. At this point you can startup your LXC container again. By doing it this way, nothing needed to happen with the nine container stack I brought over -- everything just worked as it had previously with Docker running on a Debian 11 bare metal host. The fstab lines above were brought over from my previous install, with only the UID and PID changed and x-systemd.automount added for better persistence.
Assuming a fairly typical Docker container where UID and PID 1000 are being used, nothing needs to be done in the LXC container other than shutting it down.
As root on the PVE host, create the directories you'd like to mount to Samba shares. I have three to mount, so it looks like this:
Code:
mkdir /mnt/tv_series
mkdir /mnt/movies
mkdir /mnt/backup
These are the same names I used on the system I'm transferring these containers over from, to keep things easy.
Edit /etc/fstab similar to this (with appropriate modifications for your scenario), with your favorite editor -- I like WinSCP for this purpose (and for most PVE admin that can't be done from the WebUI):
Code:
//media-server/tv\040series /mnt/tv_series cifs x-systemd.automount,username=User\040Name,password=Password,uid=101000,gid=101000 0 0
//media-server/movies /mnt/movies cifs x-systemd.automount,username=User\040Name,password=Password,uid=101000,gid=101000 0 0
//media-server/backup /mnt/backup cifs x-systemd.automount,username=User\040Name,password=Password,uid=101000,gid=101000 0 0
Since Windows usernames and shares can have spaces in them -- note that I'm showing how to handle those above using \040 in place of the <space>. UID and PID 101000 on the host get translated to 1000 on the guest. mount -a will reload fstab, and make your shares live, which you can check from the command line or in WinSCP by navigating to your sub-directories under /mnt.
And lastly, the container config file, which in my case is /etc/pve/lxc/105.conf, needs to have lines added similar to these (adapted for your use-case of course):
Code:
mp0: /mnt/tv_series/,mp=/mnt/tv_series
mp1: /mnt/movies/,mp=/mnt/movies
mp3: /mnt/backup/,mp=/mnt/backup
Note that I'm using the same names for the container mount points as I am for the host mounts -- use different names if it suits, but keeping it consistent makes more sense to me. At this point you can startup your LXC container again. By doing it this way, nothing needed to happen with the nine container stack I brought over -- everything just worked as it had previously with Docker running on a Debian 11 bare metal host. The fstab lines above were brought over from my previous install, with only the UID and PID changed and x-systemd.automount added for better persistence.