Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/podman/common/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
enchelpers "github.com/containers/ocicrypt/helpers"
"github.com/containers/podman/v5/cmd/podman/registry"
"github.com/containers/podman/v5/cmd/podman/utils"
"github.com/containers/podman/v5/libpod"
"github.com/containers/podman/v5/pkg/domain/entities"
"github.com/containers/podman/v5/pkg/env"
"github.com/openshift/imagebuilder"
Expand Down Expand Up @@ -453,6 +454,12 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil
runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
}

configIndex := libpod.RuntimeNameToConfigIndex(podmanConfig.RuntimePath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you cannot import libpod into the remote client, this function would need to live elsewhere but really I would say just inline this


for _, arg := range podmanConfig.ContainersConfDefaultsRO.Engine.OCIRuntimesFlags[configIndex] {
runtimeFlags = append(runtimeFlags, "--"+arg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is right, compared to podmanConfig.RuntimeFlags this will always append. I would assume if we set --runtime-flag on the cli it should overwrite the config file and not always add as append?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make it hard to have system-wide configuration default (e.g. logging options or whatever), and set unrelated options preserving the system-wide default.

}

platforms, err := parse.PlatformsFromOptions(c)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions docs/source/markdown/options/runtime-flag.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

Adds global flags for the container runtime. To list the supported flags, please consult the manpages of the selected container runtime.

Default runtime flags can be added in containers.conf.

Note: Do not pass the leading -- to the flag. To pass the runc flag --log-format json to buildah build, the option given is --runtime-flag log-format=json.
2 changes: 2 additions & 0 deletions docs/source/markdown/podman.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ consult the manpages of the selected container runtime (`runc` is the default
runtime, the manpage to consult is `runc(8)`. When the machine is configured
for cgroup V2, the default runtime is `crun`, the manpage to consult is `crun(8)`.).

Default runtime flags can be added in containers.conf.

Note: Do not pass the leading `--` to the flag. To pass the runc flag `--log-format json`
to podman build, the option given can be `--runtime-flag log-format=json`.

Expand Down
13 changes: 9 additions & 4 deletions libpod/oci_conmon_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ func newConmonOCIRuntime(name string, paths []string, conmonPath string, runtime
supportsKVM[r] = true
}

configIndex := RuntimeNameToConfigIndex(name)

for _, arg := range runtimeCfg.Engine.OCIRuntimesFlags[configIndex] {
runtimeFlags = append(runtimeFlags, "--"+arg)
}

runtime := new(ConmonOCIRuntime)
runtime.name = name
runtime.conmonPath = conmonPath
Expand All @@ -108,10 +114,9 @@ func newConmonOCIRuntime(name string, paths []string, conmonPath string, runtime
// TODO: probe OCI runtime for feature and enable automatically if
// available.

base := filepath.Base(name)
runtime.supportsJSON = supportsJSON[base]
runtime.supportsNoCgroups = supportsNoCgroups[base]
runtime.supportsKVM = supportsKVM[base]
runtime.supportsJSON = supportsJSON[configIndex]
runtime.supportsNoCgroups = supportsNoCgroups[configIndex]
runtime.supportsKVM = supportsKVM[configIndex]

foundPath := false
for _, path := range paths {
Expand Down
4 changes: 4 additions & 0 deletions libpod/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,7 @@ func isDirectory(path string) bool {
}
return info.IsDir()
}

func RuntimeNameToConfigIndex(runtimeName string) string {
return filepath.Base(runtimeName)
}
3 changes: 3 additions & 0 deletions vendor/github.com/containers/common/pkg/config/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/containers/common/pkg/config/containers.conf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.