如何将文件复制到 LXC 容器

一旦你使用类似这样的命令创建了 LXC 容器

lxc_launch_example.sh
lxc launch ubuntu:18.04 mycontainer

你可以使用以下命令将文件推送到容器

lxc_file_push_example.txt
lxc file push myfile.zip mycontainer/root/

这会将本地文件 myfile.zip 复制到容器上的 /root/myfile.zip。**确保你的路径以 / 结尾,**因为 lxc file push myfile.zip mycontainer/root 会显示此错误消息:

lxc_file_push_error.txt
Error: Path already exists as a directory: File too large

在这种情况下,在目标路径末尾添加斜杠(/)(例如 mycontainer/root => mycontainer/root/)。


Check out similar posts by category: Container, LXC