Use correct target paths inside rootfs path for bind mounts
This commit is contained in:
parent
54c81ae7ec
commit
4e07be3754
1 changed files with 6 additions and 3 deletions
|
|
@ -136,9 +136,12 @@ void LxcContainer::start(const Configuration &configuration) {
|
||||||
if (fs::is_directory(bind_mount.first)) create_type = "dir";
|
if (fs::is_directory(bind_mount.first)) create_type = "dir";
|
||||||
|
|
||||||
auto target_path = bind_mount.second;
|
auto target_path = bind_mount.second;
|
||||||
// LXC wants target paths relative to the container rootfs so
|
// The target path needs to be absolute and pointing to the right
|
||||||
// prividing an absolute path doesn't work.
|
// location inside the target rootfs as otherwise we get problems
|
||||||
if (utils::string_starts_with(target_path, "/")) target_path.erase(0, 1);
|
// when running in confined environments like snap's.
|
||||||
|
if (!utils::string_starts_with(target_path, "/"))
|
||||||
|
target_path = std::string("/") + target_path;
|
||||||
|
target_path = config::rootfs_path() + target_path;
|
||||||
|
|
||||||
set_config_item(
|
set_config_item(
|
||||||
"lxc.mount.entry",
|
"lxc.mount.entry",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue