[lxc-users] bind mounting a directory, not the whole /home/user

Ricardo Filipe Soares Garcia da ricardo.garcia.silva at gmail.com
Sun Dec 31 23:46:23 UTC 2017


Hi all

I'm trying to set up a workflow for software development using lxd. For
this I'd like to mount my ~/dev directory inside lxd containers. Looking
around I've found [1] and [2] and have adapted the described procedure to
my case, which seems to differ only in the fact that I don't want to mount
my whole home directory inside a container, only ~/dev.

Unfortunately what is happening is that:
- I can successfully mount ~/dev inside containers with the correct user
mappings. I can create/remove files from inside/outside a container - this
is great
- The containers are created in such a way that makes the home directory be
owned by root and not by the normal user. This means that inside the
container I am unable to write to my own home dir, even though I can write
to ~/dev. I can work around this by entering the container and issuing a
chown command  to my home dir, but this feels wrong. I think something is
not right somehow.

How would I be able to successfully have the home dir of the container's
user by writable by said user?

I'm attaching the contents of relevant files to the end of this e-mail.


Thanks in advance



[1] -
https://stgraber.org/2017/06/15/custom-user-mappings-in-lxd-containers/
[2] - https://gist.github.com/bloodearnest/ebf044476e70c4baee59c5000a10f4c8



# contents of /etc/subuid
ricardo:100000:65536
lxd:165536:65536
root:165536:65536
root:1000:1
lxd:1000:1

# contents of /etc/subgid
ricardo:100000:65536
lxd:165536:65536
root:165536:65536
root:1000:1
lxd:1000:1

# my custom lxc profile
config:
  raw.idmap: both 1000 1000
  user.vendor-data: |
    #cloud-config
    users:
      - name: ricardo
        lock_passwd: true
        shell: /bin/bash
        sudo: 'All=(All) NOPASSWD:ALL'
        groups: users, admin
description: Allow mounting dirs inside container
devices:
  dev:
    path: home/ricardo/dev
    source: /home/ricardo/dev
    type: disk
name: ricardo

# how I am creating lxc containers
lxc launch ubuntu:16.04 test --profile default --profile ricardo


-- 
___________________________ ___ __
Ricardo Garcia Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20171231/7e939d07/attachment-0001.html>


More information about the lxc-users mailing list