Best way to access files insider container

(Nik S Firefly) #1

What is the optimal-best way to access files from container?
I found

Is there any other way beside file lxc pull/push or something like nfs/sshfs?

(Turtle0x1) #2

You could have a shared disk ? ask ubuntu has a question answer although the docs are probably better


Best way depends on your use case. I use all my containers as server. So following a post of the LXD project leader saying he was considering containers as small computers I tend more and more to use standard tools like sftp, not lxd specific tools like lxc file or shared disks. Another reason is that if moving a container from a local setup to a distant one, or the reverse, it’s easier to adapt the file transfers. If I have on my local computer a sharing between the disk of my computer and a container, when I move the container on the cloud the disk sharing will not work anymore. If I use sftp, it’s only a matter of changing network paths.
OTHO if you need high performance disk sharing can be necessary.

(Nik S Firefly) #4

I agree but there is small caveat, when you backup files from container
you put access credentials in container.
If there is a good performance disk sharing we can put safely credentials
on host and backup files from containers.

(Alexander) #5

It depends on the filesystem that you use for LXC/LXD. I personally use ext4 so each container is just a sub directory on the host. I can use any file manager on the host do directly access any file in the container (e.g. Midnight Commander or WinSCP for remote hosts). You just need to correct UID/GUI for unprivileged containers if you create files in the container sub directory.