Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
nottrobin
/
setup-lxc-shared-directory.sh
Last active
Jan 20, 2017
Star
4
Fork
2
Star
Code
Revisions
2
Stars
4
Forks
2
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
How to set up a *writeable* shared directory in an LXC/LXD container
Raw
setup-lxc-shared-directory.sh
[robin@xps
~
]$ lxc launch ubuntu:16.04 my-xenial
#
Create & start a new container
[robin@xps
~
]$ getfacl ./share/
#
Check extended permissions on "share" directory
#
file: share
#
owner: robin
#
group: robin
user::rwx
group::rwx
other::r-x
[robin@xps
~
]$ sudo ls -ld /var/lib/lxd/containers/my-xenial
#
Find the user ID for my container (165536)
[sudo] password
for
robin:
drwxr-xr-x+ 4 165536 165536 4096 May 13 08:59 /var/lib/lxd/containers/my-xenial
[robin@xps
~
]$
#
Give my container access to the "share" directory
[robin@xps
~
]$ setfacl -Rm user:lxd:rwx,default:user:lxd:rwx,user:165536:rwx,default:user:165536:rwx share
[robin@xps
~
]$ getfacl share
#
Behold the new expanded permissions!
#
file: share
#
owner: robin
#
group: robin
user::rwx
user:lxd:rwx
user:165536:rwx
group::rwx
mask::rwx
other::r-x
default:user::rwx
default:user:lxd:rwx
default:user:165536:rwx
default:group::rwx
default:mask::rwx
default:other::r-x
[robin@xps
~
]$
#
Add the shared directory to the container as a device
[robin@xps
~
]$ lxc config device add my-xenial share disk source=
`
pwd
`
/share path=/srv/share
Device share added to my-xenial
[robin@xps
~
]$
#
I can now successfully create a new file in the shared directory
[robin@xps
~
]$ lxc
exec
my-xenial -- touch /srv/share/anewfile
[robin@xps
~
]$ ls -l share/anewfile
-rw-rw-r--+ 1 165536 165536 0 May 13 14:22 share/anewfile
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.