mirror of
https://github.com/containers/podman.git
synced 2025-06-27 05:26:50 +08:00
Merge pull request #17993 from xduugu/quadlet-tmpfs
quadlet: implement `Tmpfs` option
This commit is contained in:
@ -121,6 +121,7 @@ Valid options for `[Container]` are listed below:
|
|||||||
| SecurityLabelLevel=s0:c1,c2 | --security-opt label=level:s0:c1,c2 |
|
| SecurityLabelLevel=s0:c1,c2 | --security-opt label=level:s0:c1,c2 |
|
||||||
| SecurityLabelType=spc_t | --security-opt label=type:spc_t |
|
| SecurityLabelType=spc_t | --security-opt label=type:spc_t |
|
||||||
| Timezone=local | --tz local |
|
| Timezone=local | --tz local |
|
||||||
|
| Tmpfs=/work | --tmpfs /work |
|
||||||
| User=bin | --user bin |
|
| User=bin | --user bin |
|
||||||
| VolatileTmp=true | --tmpfs /tmp |
|
| VolatileTmp=true | --tmpfs /tmp |
|
||||||
| Volume=/source:/dest | --volume /source:/dest |
|
| Volume=/source:/dest | --volume /source:/dest |
|
||||||
@ -450,6 +451,13 @@ Set the label process type for the container processes.
|
|||||||
Use a Podman secret in the container either as a file or an environment variable.
|
Use a Podman secret in the container either as a file or an environment variable.
|
||||||
This is equivalent to the Podman `--secret` option and generally has the form `secret[,opt=opt ...]`
|
This is equivalent to the Podman `--secret` option and generally has the form `secret[,opt=opt ...]`
|
||||||
|
|
||||||
|
### `Tmpfs=`
|
||||||
|
|
||||||
|
Mount a tmpfs in the container. This is equivalent to the Podman `--tmpfs` option, and
|
||||||
|
generally has the form `CONTAINER-DIR[:OPTIONS]`.
|
||||||
|
|
||||||
|
This key can be listed multiple times.
|
||||||
|
|
||||||
### `Timezone=` (if unset uses system-configured default)
|
### `Timezone=` (if unset uses system-configured default)
|
||||||
|
|
||||||
The timezone to run the container in.
|
The timezone to run the container in.
|
||||||
|
@ -94,6 +94,7 @@ const (
|
|||||||
KeySecurityLabelType = "SecurityLabelType"
|
KeySecurityLabelType = "SecurityLabelType"
|
||||||
KeySecret = "Secret"
|
KeySecret = "Secret"
|
||||||
KeyTimezone = "Timezone"
|
KeyTimezone = "Timezone"
|
||||||
|
KeyTmpfs = "Tmpfs"
|
||||||
KeyType = "Type"
|
KeyType = "Type"
|
||||||
KeyUser = "User"
|
KeyUser = "User"
|
||||||
KeyVolatileTmp = "VolatileTmp"
|
KeyVolatileTmp = "VolatileTmp"
|
||||||
@ -152,6 +153,7 @@ var (
|
|||||||
KeySecurityLabelLevel: true,
|
KeySecurityLabelLevel: true,
|
||||||
KeySecurityLabelType: true,
|
KeySecurityLabelType: true,
|
||||||
KeySecret: true,
|
KeySecret: true,
|
||||||
|
KeyTmpfs: true,
|
||||||
KeyTimezone: true,
|
KeyTimezone: true,
|
||||||
KeyUser: true,
|
KeyUser: true,
|
||||||
KeyVolatileTmp: true,
|
KeyVolatileTmp: true,
|
||||||
@ -474,6 +476,15 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmpfsValues := container.LookupAll(ContainerGroup, KeyTmpfs)
|
||||||
|
for _, tmpfs := range tmpfsValues {
|
||||||
|
if strings.Count(tmpfs, ":") > 1 {
|
||||||
|
return nil, fmt.Errorf("invalid tmpfs format '%s'", tmpfs)
|
||||||
|
}
|
||||||
|
|
||||||
|
podman.add("--tmpfs", tmpfs)
|
||||||
|
}
|
||||||
|
|
||||||
volumes := container.LookupAll(ContainerGroup, KeyVolume)
|
volumes := container.LookupAll(ContainerGroup, KeyVolume)
|
||||||
for _, volume := range volumes {
|
for _, volume := range volumes {
|
||||||
parts := strings.SplitN(volume, ":", 3)
|
parts := strings.SplitN(volume, ":", 3)
|
||||||
|
@ -582,4 +582,29 @@ EOF
|
|||||||
rm -rf $tmp_path
|
rm -rf $tmp_path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "quadlet - tmpfs" {
|
||||||
|
local quadlet_file=$PODMAN_TMPDIR/basic_$(random_string).container
|
||||||
|
cat > $quadlet_file <<EOF
|
||||||
|
[Container]
|
||||||
|
Image=$IMAGE
|
||||||
|
Exec=top
|
||||||
|
Tmpfs=/tmpfs1
|
||||||
|
Tmpfs=/tmpfs2:ro
|
||||||
|
EOF
|
||||||
|
|
||||||
|
run_quadlet "$quadlet_file"
|
||||||
|
service_setup $QUADLET_SERVICE_NAME
|
||||||
|
|
||||||
|
run_podman container inspect --format '{{index .HostConfig.Tmpfs "/tmpfs1"}}' $QUADLET_CONTAINER_NAME
|
||||||
|
is "$output" "rw,rprivate,nosuid,nodev,tmpcopyup" "regular tmpfs mount"
|
||||||
|
|
||||||
|
run_podman container inspect --format '{{index .HostConfig.Tmpfs "/tmpfs2"}}' $QUADLET_CONTAINER_NAME
|
||||||
|
is "$output" "ro,rprivate,nosuid,nodev,tmpcopyup" "read-only tmpfs mount"
|
||||||
|
|
||||||
|
run_podman container inspect --format '{{index .HostConfig.Tmpfs "/tmpfs3"}}' $QUADLET_CONTAINER_NAME
|
||||||
|
is "$output" "" "nonexistent tmpfs mount"
|
||||||
|
|
||||||
|
service_cleanup $QUADLET_SERVICE_NAME failed
|
||||||
|
}
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
Reference in New Issue
Block a user