Problem

Access the files inside a LXC container in order to show them or copy them.

Analysis

To access LXC container filesystem use the following trick:

The following command

# lxc-info -n p1 -p -H

prints the process number of the respective container where p1 is the container number

Solution

We can use this process number to access the container’s file system. For example to list the container’s root directory execute the following:



# ls -lh /proc/$(lxc-info -n p1 -p -H)/root/

where p1 is the container number. You can copy files also by using this logic.

# cp anyfile /proc/$(lxc-info -n p1 -p -H)/root/destdir/
How to access LXC container’s filesystem from the main host
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *