podman icon indicating copy to clipboard operation
podman copied to clipboard

containers.conf [containers] init=true is ignored

Open mwdle opened this issue 1 month ago • 3 comments

Issue Description

Setting init=true under [containers] in containers.conf does not enable an init process when the --init option is omitted.

The containers.conf documentation describes init:

Run an init inside the container that forwards signals and reaps processes.

And explicitly providing --init=true does work, demonstrating that the init binary is available. However, the equivalent file-configured default is ignored.

Steps to reproduce the issue

  1. Add the following to ~/.config/containers/containers.conf:
[containers]
init=true
  1. Run the same container with the init option omitted, enabled, and disabled and observe the result:
printf 'init omitted: '
podman run --rm docker.io/library/alpine:latest cat /proc/1/comm

printf 'init=true: '
podman run --rm --init=true docker.io/library/alpine:latest cat /proc/1/comm

printf 'init=false: '
podman run --rm --init=false docker.io/library/alpine:latest cat /proc/1/comm

Describe the results you received

The configured default is ignored when --init is omitted:

init omitted: cat
init=true: podman-init
init=false: cat

Describe the results you expected

The container that ran with the --init option omitted should inherit init=true from containers.conf:

init omitted: podman-init
init=true: podman-init
init=false: cat

podman info output

host:
  arch: amd64
  buildahVersion: 1.45.2
  cdiSpecDirs:
  - /etc/cdi
  - /var/run/cdi
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.2.1-2.fc45.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.2.1, commit: '
  cpuUtilization:
    idlePercent: 86.17
    systemPercent: 5.48
    userPercent: 8.34
  cpus: 6
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: server
    version: "45"
  emulatedArchitectures:
  - linux/arm
  - linux/arm64
  - linux/arm64be
  - linux/loong64
  - linux/mips
  - linux/mips64
  - linux/ppc
  - linux/ppc64
  - linux/ppc64le
  - linux/riscv32
  - linux/riscv64
  - linux/s390x
  eventLogger: journald
  freeLocks: 2012
  hostname: lab
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 1000000000
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 1000000000
  kernel: 7.2.12-300.fc45.x86_64
  linkmode: dynamic
  logDriver: journald
  memAvailable: 11133108224
  memFree: 448528384
  memTotal: 16522424320
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    defaultNetwork: podman
    dns:
      package: aardvark-dns-2.1.0-1.fc45.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 2.1.0
    package: netavark-2.1.0-1.fc45.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 2.1.0
  ociRuntime:
    name: crun
    package: crun-1.30.1-1.fc45.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.30.1
      commit: 079ff6a7a16d029460af882f9ea44674e6a510b6
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +JSON_C
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20261002.gcba3570-1.fc45.x86_64
    version: |
      pasta 0^20261002.gcba3570-1.fc45.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  rootlessNetworkCmd: pasta
  rootlessPortForwarder: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  swapFree: 7171178496
  swapTotal: 8589930496
  uptime: 46h 24m 52.00s (Approximately 1.92 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
store:
  containerStore:
    number: 23
    paused: 0
    running: 23
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev
  graphRoot: /home/mwdle/.local/share/containers/storage
  graphRootAllocated: 498387124224
  graphRootUsed: 287070195712
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 118
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/mwdle/.local/share/containers/storage/volumes
version:
  APIVersion: 6.1.4
  BuildOrigin: Fedora Project
  Built: 1791763200
  BuiltTime: Sun Oct 11 18:00:00 2026
  GitCommit: 464c15fec06f0074c916f9eff87c4806869c2833
  GoVersion: go1.27.1-X:nodwarf5
  Os: linux
  OsArch: linux/amd64
  Version: 6.1.4

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

I have reproduced the issue on various systems as well as running Podman in a container.

Additional information

In Podman v6.1.4, the command-line --init option appears to be registered with a hard-coded false default and does not honor or merge in the value defined in containers.conf

https://github.com/podman-container-tools/podman/blob/v6.1.4/cmd/podman/common/create.go#L181-L185

mwdle avatar Nov 01 '26 02:11 mwdle

Hi, I'd be happy to give this a go.

nadav78 avatar Nov 01 '26 10:11 nadav78

@nadav78 Thank you for working on this! 🙌

Does your change also cover containers created through the Docker-compatible socket/API?

For this issue, I provided the simplest reproducible example I could think of. However, I wanted to clarify that my primary use case is Jenkins Docker Plugin communicating with Podman through its socket, in case that makes a difference.

From what I understand, the Jenkins Docker plugin omits HostConfig.Init, so I need the server-side containers.conf value to apply. As a similar example, I can confirm that another containers.conf default, userns="nomap", correctly applies to containers created by Jenkins.

I see that this PR changes the CLI flag default in cmd/podman/common/create.go. Could you confirm whether container creation via the Docker-compatible API passes through the same code? I’m not familiar enough with Podman’s internals to fully understand the flow here, but I noticed that the separate pkg/api/handlers/compat/containers_create.go appears to turn an omitted HostConfig.Init into false.

If the API uses a separate flow, could support for the server-side init default be included here?

mwdle avatar Nov 02 '26 00:11 mwdle

@mwdle you're right, my change only fixes the CLI path. I extended the fix

nadav78 avatar Nov 02 '26 07:11 nadav78