mirror of
https://github.com/containers/podman.git
synced 2025-10-19 20:23:08 +08:00
quadlet: Add support for Network=...
This just gets translated to --network=... Signed-off-by: Alexander Larsson <alexl@redhat.com>
This commit is contained in:
@ -234,6 +234,12 @@ created by using a `$name.volume` quadlet file.
|
||||
|
||||
This key can be listed multiple times.
|
||||
|
||||
#### `Network=`
|
||||
|
||||
Specify a custom network for the container. This has the same format as the `--network` option
|
||||
to `podman run`. For example, use `host` to use the host network in the container, or `none` to
|
||||
not set up networking in the container.
|
||||
|
||||
#### `ExposeHostPort=`
|
||||
|
||||
Exposes a port, or a range of ports (e.g. `50-59`), from the host to the container. Equivalent
|
||||
|
@ -72,6 +72,7 @@ const (
|
||||
KeyTimezone = "Timezone"
|
||||
KeySeccompProfile = "SeccompProfile"
|
||||
KeyAddDevice = "AddDevice"
|
||||
KeyNetwork = "Network"
|
||||
)
|
||||
|
||||
// Supported keys in "Container" group
|
||||
@ -106,6 +107,7 @@ var supportedContainerKeys = map[string]bool{
|
||||
KeyTimezone: true,
|
||||
KeySeccompProfile: true,
|
||||
KeyAddDevice: true,
|
||||
KeyNetwork: true,
|
||||
}
|
||||
|
||||
// Supported keys in "Volume" group
|
||||
@ -371,6 +373,11 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile
|
||||
podman.addf("--tz=%s", timezone)
|
||||
}
|
||||
|
||||
network, ok := container.Lookup(ContainerGroup, KeyNetwork)
|
||||
if ok && len(network) > 0 {
|
||||
podman.addf("--network=%s", network)
|
||||
}
|
||||
|
||||
// Run with a pid1 init to reap zombies by default (as most apps don't do that)
|
||||
runInit := container.LookupBoolean(ContainerGroup, KeyRunInit, true)
|
||||
if runInit {
|
||||
|
5
test/e2e/quadlet/network.container
Normal file
5
test/e2e/quadlet/network.container
Normal file
@ -0,0 +1,5 @@
|
||||
## assert-podman-args "--network=host"
|
||||
|
||||
[Container]
|
||||
Image=localhost/imagename
|
||||
Network=host
|
@ -278,6 +278,7 @@ var _ = Describe("quadlet system generator", func() {
|
||||
Entry("install.container", "install.container"),
|
||||
Entry("label.container", "label.container"),
|
||||
Entry("name.container", "name.container"),
|
||||
Entry("network.container", "network.container"),
|
||||
Entry("noimage.container", "noimage.container"),
|
||||
Entry("noremapuser2.container", "noremapuser2.container"),
|
||||
Entry("noremapuser.container", "noremapuser.container"),
|
||||
|
Reference in New Issue
Block a user