mirror of
https://github.com/apple/container.git
synced 2026-10-19 04:29:17 +00:00
LinuxPod: Support per container dns/hosts (#496)
This shouldn't have been pod level, and we had no way to set hosts today either. This just exposes hosts and the dns configs per container now.
This commit is contained in:
1 parent
fd62f311b4
commit
db113ffec9
3 files changed
+184
-7
No files matched your search
@@ -44,8 +44,6 @@ public final class LinuxPod: Sendable {
|
||||
public var memoryInBytes: UInt64 = 1024.mib()
|
||||
/// The network interfaces for the pod.
|
||||
public var interfaces: [any Interface] = []
|
||||
/// The DNS configuration for the pod.
|
||||
public var dns: DNS?
|
||||
/// Whether nested virtualization should be turned on for the pod.
|
||||
public var virtualization: Bool = false
|
||||
/// Optional file path to store serial boot logs.
|
||||
@@ -73,6 +71,10 @@ public final class LinuxPod: Sendable {
|
||||
public var mounts: [Mount] = LinuxContainer.defaultMounts()
|
||||
/// The Unix domain socket relays to setup for the container.
|
||||
public var sockets: [UnixSocketConfiguration] = []
|
||||
/// The DNS configuration for the container.
|
||||
public var dns: DNS?
|
||||
/// The hosts file configuration for the container.
|
||||
public var hosts: Hosts?
|
||||
|
||||
public init() {}
|
||||
}
|
||||
@@ -433,15 +435,20 @@ extension LinuxPod {
|
||||
}
|
||||
}
|
||||
|
||||
// Setup /etc/resolv.conf if asked for
|
||||
if let dns = self.config.dns {
|
||||
// Configure DNS in each container's rootfs
|
||||
for (_, container) in containers {
|
||||
// Setup /etc/resolv.conf and /etc/hosts for each container
|
||||
for (_, container) in containers {
|
||||
if let dns = container.config.dns {
|
||||
try await agent.configureDNS(
|
||||
config: dns,
|
||||
location: Self.guestRootfsPath(container.id)
|
||||
)
|
||||
}
|
||||
if let hosts = container.config.hosts {
|
||||
try await agent.configureHosts(
|
||||
config: hosts,
|
||||
location: Self.guestRootfsPath(container.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user