Maciej

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 -

--

--

Maciej

Maciej

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