Mount CIFS/SMB shares RW in LXD containers


(Jason Bayton) #1

Originally published at: https://bayton.org/docs/linux/lxd/mount-cifssmb-shares-rw-in-lxd-containers/

One of the biggest limitations with LXD I’ve found to date is the inability to mount remote shares on unprivileged containers. While it’s still not possible at this point to mount CIFS shares from within a container directly, I’ve figured out a way to get around this by first mounting the shares on the LXD host and then using lxd config device add to mount them in my containers from there. So continuing the recent LXD theme, in this article we’ll work through mounting CIFs shares read/write on containers. Before we begin This guide assumes you already have a CIFS/SMB (referred to only as CIFS in the guide) share set up and ready to mount on your LXD containers. If you don’t, set this up first. Additionally, a container should be provisioned and ready to use. If this is not the case, create a new LXD Xenial container with the following command before continuing: lxc launch ubuntu:xenial c1 Both the host and containers are Ubuntu 16.04 LTS. The container name throughout this guide is c1. Please change this in any commands you copy into your own terminal. Warning By following this guide, any mounted CIFS shares will be visible on the LXD host and can be modified by sudo/root user(s). This method is not recommended with private shares on a shared LXD host server. Only continue if you’re happy accepting any risks associated with this configuration. Find the UID/GID of your LXD user Before we begin to look at mounting the share(s), the first step…