diff --git a/src/commands/teardown.rs b/src/commands/teardown.rs index bff0dd780..c7d919567 100644 --- a/src/commands/teardown.rs +++ b/src/commands/teardown.rs @@ -57,6 +57,7 @@ impl Teardown { container_ips_v6: Vec::new(), container_names: Vec::new(), container_dns_servers: &None, + is_internal: network.internal, }); } } diff --git a/src/dns/aardvark.rs b/src/dns/aardvark.rs index 9bad282f9..6c1314d57 100644 --- a/src/dns/aardvark.rs +++ b/src/dns/aardvark.rs @@ -29,6 +29,7 @@ pub struct AardvarkEntry<'a> { pub container_ips_v6: Vec, pub container_names: Vec, pub container_dns_servers: &'a Option>, + pub is_internal: bool, } #[derive(Debug, Clone)] @@ -221,7 +222,12 @@ impl Aardvark { } for entry in &entries { - let path = Path::new(&self.config).join(entry.network_name); + let mut path = Path::new(&self.config).join(entry.network_name); + if entry.is_internal { + let new_path = Path::new(&self.config).join(entry.network_name.to_owned() + "%int"); + let _ = std::fs::rename(&path, &new_path); + path = new_path; + } let file = match OpenOptions::new().write(true).create_new(true).open(&path) { Ok(mut f) => { @@ -326,7 +332,11 @@ impl Aardvark { } pub fn delete_entry(&self, container_id: &str, network_name: &str) -> Result<()> { - let path = Path::new(&self.config).join(network_name); + let mut path = Path::new(&self.config).join(network_name); + if !path.exists() { + path = Path::new(&self.config).join(network_name.to_owned() + "%int"); + } + let file_content = fs::read_to_string(&path)?; let lines: Vec<&str> = file_content.split_terminator('\n').collect(); diff --git a/src/network/bridge.rs b/src/network/bridge.rs index e2a4565ab..cc003f926 100644 --- a/src/network/bridge.rs +++ b/src/network/bridge.rs @@ -203,6 +203,7 @@ impl driver::NetworkDriver for Bridge<'_> { container_ips_v6: ipv6, container_names: names, container_dns_servers: self.info.container_dns_servers, + is_internal: self.info.network.internal, }) } else { // If --dns-enable=false and --dns was set then return following DNS servers