Skip to content

podman commit does not seem to be able to empty-out the image Cmd field #4625

@ifireball

Description

@ifireball

/kind bug

Description
When using podman commit it stores the Cmd used to launch the committed container. It seems that it it impossible to make it null-out the Cmd in the resulting image.

Steps to reproduce the issue:

  1. Create a container:

     $ sudo podman run -i --name foo-c centos:8 bash -xc 'echo foo > /bar.sh'
     + echo foo
    
  2. Commit it:

     $ sudo podman commit foo-c foo-img
     Getting image source signatures
     Copying blob 9e607bb861a7 skipped: already exists
     Copying blob 45de37606893 done
     Copying config a9b00dc0f2 done
     Writing manifest to image destination
     Storing signatures
     a9b00dc0f237b062e80669827e14321a2e18d9047ee21e00611f22f386105976
    
  3. Resulting image has Cmd field set:

     $ sudo podman image inspect foo-img -f json | jq -Mc '.[0].Config.Cmd'
     ["bash","-xc","echo foo > /bar.sh"]
    
  4. Now lets try to make it null:

     $ sudo podman commit --change 'CMD []' foo-c foo-img
     ...
    
  5. The result is that Cmd becomes an array with an empty string in it instead of an empty array or being not included in the image altogether.:

     $ sudo podman image inspect foo-img -f json | jq -Mc '.[0].Config.Cmd'
     [""]
    

Additional information you deem important (e.g. issue happens only occasionally):

This mat or may not be related to this old Docker bug: moby/moby#7798

Output of podman version:

podman version 1.4.4

Output of podman info --debug:

debug:
  compiler: gc
  git commit: ""
  go version: go1.10.8
  podman version: 1.4.4
host:
  BuildahVersion: 1.9.0
  Conmon:
    package: podman-1.4.4-2.el7.x86_64
    path: /usr/libexec/podman/conmon
    version: 'conmon version 0.3.0, commit: unknown'
  Distribution:
    distribution: '"rhel"'
    version: "7.6"
  MemFree: 2197884928
  MemTotal: 24744050688
  OCIRuntime:
    package: runc-1.0.0-59.dev.git2abd837.el7.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.0'
  SwapFree: 7883956224
  SwapTotal: 8589930496
  arch: amd64
  cpus: 8
  hostname: bkorren.tlv.csb
  kernel: 3.10.0-957.21.3.el7.x86_64
  os: linux
  rootless: false
  uptime: 960h 28m 45.56s (Approximately 40.00 days)
registries:
  blocked: null
  insecure: null
  search:
  - registry.access.redhat.com
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.centos.org
store:
  ConfigFile: /etc/containers/storage.conf
  ContainerStore:
    number: 5
  GraphDriverName: overlay
  GraphOptions: null
  GraphRoot: /var/lib/containers/storage
  GraphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  ImageStore:
    number: 182
  RunRoot: /var/run/containers/storage
  VolumePath: /var/lib/containers/storage/volumes

Package info (e.g. output of rpm -q podman or apt list podman):

podman-1.4.4-2.el7.x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.locked - please file new issue/PRAssist humans wanting to comment on an old issue or PR with locked comments.stale-issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions