fix(#2002): mkdir container /etc before writing bridge-DNS marker (fresh install)
This commit is contained in:
parent
8e366c8a10
commit
ad8ed452fd
1 changed files with 10 additions and 0 deletions
|
|
@ -1420,6 +1420,16 @@ fn write_bridge_dns_marker(container: &str, isolation: Option<&NetworkIsolation>
|
|||
let path = bridge_dns_marker_path(container);
|
||||
match isolation {
|
||||
Some(iso) => {
|
||||
// On a fresh install the container's `/etc` may not exist yet
|
||||
// (rootfs not fully materialised before the first start), so
|
||||
// `write` would fail with ENOENT. Create the parent dir first
|
||||
// — it's the container's own `/etc`, which nixos-container
|
||||
// populates on start; a pre-created dir + our marker persist.
|
||||
if let Some(parent) = std::path::Path::new(&path).parent() {
|
||||
std::fs::create_dir_all(parent).with_context(|| {
|
||||
format!("create bridge-DNS marker dir {}", parent.display())
|
||||
})?;
|
||||
}
|
||||
std::fs::write(&path, format!("{}\n", iso.gateway_ip))
|
||||
.with_context(|| format!("write bridge-DNS marker {path}"))?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue