Copy the Host Directory to the Container With LXC/LXD

Case

We want to copy only a specific directory of the host into the container.

Solution

If you want to copy only a specific directory instead of mounting it to the container, use the following command.

tar cf - /path/on/host | lxc exec container -- tar xvf - -C /path/on/target

It can be omitted if it is okay to expand to the current directory in the container with the same directory name as the source -C

tar cf - /path/on/host | lxc exec container -- tar xvf -

 by the author.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Maciej

Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.