LXC bind mounting NFS mount and docker containers

plato79

Member
Nov 24, 2020
24
2
8
45
Hello,

This weekend I finished configuring most of my personal server ( which is for development and fun so I don't care about security much ).. It was previously working as a nas server with Freenas and had rancher as docker host vm..

Although I wanted to have a full hypervisor with PCI-E passthrough ( NV GT 710 ) for a macOS VM and wanted to port most of the servers I was running in the FreeNAS jail to a docker container. My old Freenas jail had around 14-15 apps working as services.. Some of the services was not supported in Freenas and I created services for them.. It was a complete mess I should say..

Well, this time I started with Proxmox, first I was thinking about creating a Freenas VM and run it under Proxmox but feeling adventureous ( and maybe a bit stupid ) I imported my ZFS pools directly into Proxmox.

After that I created 2 LXC dockers. One for docker containers which I used portainer for that, and another for fileserving. I used turnkey-core for docker, and turnkey-fileserver for the other one. I created CIFS shares under fileserver LXC.

Everything was chugging along nicely until I restarted the proxmox..

TL;DR: Well, the problem was when Proxmox boots, it mounts an NFS share from another machine, and I bind mount this folder to my LXC containers.. Although I realized that LXC containers doesn't wait for this process and the docker containers under LXC using this NFS share folder has this as empty. The LXC itself sees its' contents but docker containers have only an empty folder as volume. When I restarted them, they also saw its' contents. But this is a big problem of course.

So, is there any way for the containers run after NFS mount completes so docker containers see the contents of the NFS share?
 
You can set a "startup delay" under "YourLXC -> Options" so it will wait a bit before starting the LXCs.

Or you can disable autostart of LXCs and write your own systemd script that waits until network is ready, then mount that NFS share and starts each LXC individually.
I did this as a workaround because automounting SMB shares at boot using fstab wasn't working and I always needed to manually run "mount -a" after boot to mount them. If someone knows why manually running "mount -a" is working but not automatically at boot, feel free to tell my why...
 
Last edited:
When you told me about startup delay I checked and found a solution that did it for me..

This thread explains how to delay starting up of containers and 30 seconds was enough for me to get over this hurdle.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!