Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong image tag is used when creating a container from an image with multiple tags #8547

Closed
riyad opened this issue Dec 1, 2020 · 8 comments · Fixed by #8690
Closed

Wrong image tag is used when creating a container from an image with multiple tags #8547

riyad opened this issue Dec 1, 2020 · 8 comments · Fixed by #8690
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@riyad
Copy link
Contributor

riyad commented Dec 1, 2020

/kind bug

Description

Trying to find regressions from Podman 2.1.1 by exercising the APIv2 trough docker-py's test suite (see #5386) I came across a regressions in the ListContainersTest.test_list_containers test.

When listing containers (i.e. GET /v1.40/containers/json?all=1) the "Image" field has values like `"docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c" which throws off any code that expects it to be the same as what the container was created with (here: "alpine:3.10").

What "breaks" the listing containers test is another test called ImageCollectionTest.test_save_and_load which saves an image (also "alpine:3.10" 🤨 ) into a file and loads it into the local image repository again.

NOTE: when loading the image Podman adds an extra tag in the form of "docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c" to the image where the SHA corresponds to the actual image id. Now the image has two tags! It seems Docker doesn't add the extra tag.

When we then run the original test again (i.e. ListContainersTest.test_list_containers) it's supposed to create a container from the "alpine:3.10" image. Here's where the weird thing happens: the container's the image is saved (into the BoltDB) as "docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c" (same image, but wrong tag).

Steps to reproduce the issue:

The following (trans-)script shows what happens. It can be run in the Python interpreter (assuming docker-py is installed).

import docker
import tempfile


TEST_IMG = 'alpine:3.10'


client = docker.from_env()

# POST http+docker://localhost/v1.40/images/create
image = client.images.pull(TEST_IMG)

#
# adapted from ImageCollectionTest.test_save_and_load (can be run against Podman 2.1.1 or 2.2-dev)
#

# GET http+docker://localhost/v1.40/images/alpine:3.10/json
image = client.images.get(TEST_IMG)
image.id
# => 'sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c'
image.tags
# => ['docker.io/library/alpine:3.10']

with tempfile.TemporaryFile() as f:
    # GET http+docker://localhost/v1.40/images/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c/get
    stream = image.save()
    for chunk in stream:
        f.write(chunk)
    f.seek(0)
    # POST http+docker://localhost/v1.40/images/load
    # GET http+docker://localhost/v1.40/images/docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c/json
    result = client.images.load(f.read())


loaded_image = result[0]
loaded_image.id
# => 'sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c'
loaded_image.tags
# => ['docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c', 'docker.io/library/alpine:3.10']

Describe the results you received:

This is what happens with Podman 3.0-dev:

#
# adapted from ListContainersTest.test_list_containers (with Podman 3.0-dev)
#

cntr = client.api.create_container(TEST_IMG, 'true')
# => {'Id': 'fbdfdfdbf4ddf69785275fa8bcd30a9a0e4ab8827d00552c2251de5549b6c4d9', 'Warnings': []}
cntr['Id']
# => 'fbdfdfdbf4ddf69785275fa8bcd30a9a0e4ab8827d00552c2251de5549b6c4d9'

all_containers = client.api.containers(all=True)
# => [{'Id': 'fbdfdfdbf4ddf69785275fa8bcd30a9a0e4ab8827d00552c2251de5549b6c4d9', 'Names': ['/clever_bohr'], 'Image': 'docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c', 'ImageID': 'be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c', 'Command': 'true', 'Created': 1606511556, 'Ports': None, 'Labels': {}, 'State': 'exited', 'Status': '', 'NetworkSettings': None, 'Mounts': None, 'Name': '', 'Config': None, 'NetworkingConfig': None, 'Platform': None, 'AdjustCPUShares': False}]

listed_cntr = [c for c in all_containers if c['Id'].startswith(cntr['Id'])][0]
# => [{'Id': 'fbdfdfdbf4ddf69785275fa8bcd30a9a0e4ab8827d00552c2251de5549b6c4d9', 'Names': ['/clever_bohr'], 'Image': 'docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c', 'ImageID': 'be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c', 'Command': 'true', 'Created': 1606511556, 'Ports': None, 'Labels': {}, 'State': 'exited', 'Status': '', 'NetworkSettings': None, 'Mounts': None, 'Name': '', 'Config': None, 'NetworkingConfig': None, 'Platform': None, 'AdjustCPUShares': False}]
listed_cntr['Image']
# => 'docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c'
assert listed_cntr['Image'].endswith(TEST_IMG)  # FAILS

Describe the results you expected:

This is what happens with Podman 2.1.1:

#
# adapted from ListContainersTest.test_list_containers (with Podman 2.1.1)
#

cntr = client.api.create_container(TEST_IMG, 'true')
# => {'Id': 'c76755a7abf76f8839a6d9c5fc6588c58fbb9b92831d33da9b6dffd5cce195c2', 'Warnings': []}
cntr['Id']
# => 'c76755a7abf76f8839a6d9c5fc6588c58fbb9b92831d33da9b6dffd5cce195c2'

all_containers = client.api.containers(all=True)
# => [{'Id': 'c76755a7abf76f8839a6d9c5fc6588c58fbb9b92831d33da9b6dffd5cce195c2', 'Names': ['/heuristic_chatelet'], 'Image': 'alpine:3.10', 'ImageID': 'be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c', 'Command': 'true', 'Created': 1606512387, 'Ports': None, 'Labels': {}, 'State': 'stopped', 'Status': '', 'NetworkSettings': None, 'Mounts': None, 'Name': '', 'Config': None, 'NetworkingConfig': None, 'Platform': None, 'AdjustCPUShares': False}]

listed_cntr = [c for c in all_containers if c['Id'].startswith(cntr['Id'])][0]
# => [{'Id': 'c76755a7abf76f8839a6d9c5fc6588c58fbb9b92831d33da9b6dffd5cce195c2', 'Names': ['/heuristic_chatelet'], 'Image': 'alpine:3.10', 'ImageID': 'be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c', 'Command': 'true', 'Created': 1606512387, 'Ports': None, 'Labels': {}, 'State': 'stopped', 'Status': '', 'NetworkSettings': None, 'Mounts': None, 'Name': '', 'Config': None, 'NetworkingConfig': None, 'Platform': None, 'AdjustCPUShares': False}]
listed_cntr['Image']
# => 'alpine:3.10'
assert listed_cntr['Image'].endswith(TEST_IMG)  # PASSES

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

This worked on Podman 2.1.1 and fails on 3.0-dev (currently: b2cd6e0).

Output of podman version:

Version:      2.1.1
API Version:  2.0.0
Go Version:   go1.15.2
Built:        Thu Jan  1 01:00:00 1970
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.16.1
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: 'conmon: /usr/libexec/podman/conmon'
    path: /usr/libexec/podman/conmon
    version: 'conmon version 2.0.20, commit: '
  cpus: 4
  distribution:
    distribution: ubuntu
    version: "20.04"
  eventLogger: journald
  hostname: acnologia
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.4.0-54-generic
  linkmode: dynamic
  memFree: 796901376
  memTotal: 16544563200
  ociRuntime:
    name: crun
    package: Unknown
    path: /usr/local/bin/crun
    version: |-
      crun version 0.16
      commit: 91ec195708efb8eed1699d59cd0369d639d8a7a8
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  rootless: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: 'slirp4netns: /usr/bin/slirp4netns'
    version: |-
      slirp4netns version 1.1.7
      commit: unknown
      libslirp: 4.3.1-git
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.4.3
  swapFree: 1684824064
  swapTotal: 2147479552
  uptime: 110h 40m 34.23s (Approximately 4.58 days)
registries:
  search:
  - docker.io
store:
  configFile: /home/riyad/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 1
    stopped: 1
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: 'fuse-overlayfs: /usr/bin/fuse-overlayfs'
      Version: |-
        fusermount3 version: 3.9.0
        fuse-overlayfs: version 1.1.0
        FUSE library version 3.9.0
        using FUSE kernel interface version 7.31
    overlay.mountopt: nodev
  graphRoot: /home/riyad/podman/storage
  graphStatus:
    Backing Filesystem: zfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 18
  runRoot: /run/user/1000
  volumePath: /home/riyad/podman/storage/volumes
version:
  APIVersion: 2.0.0
  Built: 0
  BuiltTime: Thu Jan  1 01:00:00 1970
  GitCommit: ""
  GoVersion: go1.15.2
  OsArch: linux/amd64
  Version: 2.1.1

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

podman/unknown 2.2.0~0.1+nmu3 amd64 [upgradable from: 2.1.1~2]
podman/unknown 2.2.0~0.1+nmu3 arm64
podman/unknown 2.2.0~0.1+nmu3 armhf
podman/unknown 2.2.0~0.1+nmu3 s390x

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 1, 2020
@riyad
Copy link
Contributor Author

riyad commented Dec 8, 2020

There seems to be a deeper problem. I was able to reproduce this error with the CLI also.
Starting a container with a specific tag (where the image has multiple) it seems to loose the original tag and picks one "at random" (it doesn't seem to be the "first", see examples below 🤷). FWIW it's at least consistent in its picks: creating
the same containers again picks the same wrong image names (see "ImageName" in output from podman inspect) over and over.

Assuming we have these images:

$ podman version
Version:      2.1.1
API Version:  2.0.0
Go Version:   go1.15.2
Built:        Thu Jan  1 01:00:00 1970
OS/Arch:      linux/amd64

$ podman image ls
REPOSITORY                TAG                                                               IMAGE ID      CREATED        SIZE
docker.io/library/alpine  latest                                                            d6e46aa2470d  6 weeks ago    5.85 MB
docker.io/library/alpine  3.12                                                              d6e46aa2470d  6 weeks ago    5.85 MB
docker.io/library/alpine  3.10                                                              be4e4bea2c2e  7 months ago   5.84 MB
docker.io/library/sha256  be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c  be4e4bea2c2e  7 months ago   5.84 MB

Test with alpine:3.12

$ podman create alpine:3.12 true 
1eff06c0155487862af70a56a61a5ee57c95a7ff1fba28d29513048c8f1d041a
$ podman inspect 1eff06c0155487862af70a56a61a5ee57c95a7ff1fba28d29513048c8f1d041a
[
    {
        "Id": "1eff06c0155487862af70a56a61a5ee57c95a7ff1fba28d29513048c8f1d041a",
        "Created": "2020-12-08T11:38:53.591158883+01:00",
        "Path": "true",
        "Args": [
            "true"
        ],
        "State": {
            "OciVersion": "1.0.2-dev",
            "Status": "configured",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "0001-01-01T00:00:00Z",
            "FinishedAt": "0001-01-01T00:00:00Z",
            "Healthcheck": {
                "Status": "",
                "FailingStreak": 0,
                "Log": null
            }
        },
        "Image": "d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0",
        "ImageName": "docker.io/library/alpine:latest",
        "Rootfs": "",
        "Pod": "",
        "ResolvConfPath": "",
        "HostnamePath": "",
        "HostsPath": "",
        "StaticDir": "/home/riyad/podman/storage/overlay-containers/1eff06c0155487862af70a56a61a5ee57c95a7ff1fba28d29513048c8f1d041a/userdata",
        "OCIRuntime": "crun",
        "LogPath": "/home/riyad/podman/storage/overlay-containers/1eff06c0155487862af70a56a61a5ee57c95a7ff1fba28d29513048c8f1d041a/userdata/ctr.log",
        "LogTag": "",
        "ConmonPidFile": "/run/user/1000/overlay-containers/1eff06c0155487862af70a56a61a5ee57c95a7ff1fba28d29513048c8f1d041a/userdata/conmon.pid",
        "Name": "gracious_dhawan",
        "RestartCount": 0,
        "Driver": "overlay",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "EffectiveCaps": [
            "CAP_AUDIT_WRITE",
            "CAP_CHOWN",
            "CAP_DAC_OVERRIDE",
            "CAP_FOWNER",
            "CAP_FSETID",
            "CAP_KILL",
            "CAP_MKNOD",
            "CAP_NET_BIND_SERVICE",
            "CAP_NET_RAW",
            "CAP_SETFCAP",
            "CAP_SETGID",
            "CAP_SETPCAP",
            "CAP_SETUID",
            "CAP_SYS_CHROOT"
        ],
        "BoundingCaps": [
            "CAP_AUDIT_WRITE",
            "CAP_CHOWN",
            "CAP_DAC_OVERRIDE",
            "CAP_FOWNER",
            "CAP_FSETID",
            "CAP_KILL",
            "CAP_MKNOD",
            "CAP_NET_BIND_SERVICE",
            "CAP_NET_RAW",
            "CAP_SETFCAP",
            "CAP_SETGID",
            "CAP_SETPCAP",
            "CAP_SETUID",
            "CAP_SYS_CHROOT"
        ],
        "ExecIDs": [],
        "GraphDriver": {
            "Name": "overlay",
            "Data": {
                "LowerDir": "/home/riyad/podman/storage/overlay/ace0eda3e3be35a979cec764a3321b4c7d0b9e4bb3094d20d3ff6782961a8d54/diff",
                "UpperDir": "/home/riyad/podman/storage/overlay/28e060cf845627337d5fb7a6f06763c4fd6d1e78608a96064f44639ae0d757a6/diff",
                "WorkDir": "/home/riyad/podman/storage/overlay/28e060cf845627337d5fb7a6f06763c4fd6d1e78608a96064f44639ae0d757a6/work"
            }
        },
        "Mounts": [],
        "Dependencies": [],
        "NetworkSettings": {
            "EndpointID": "",
            "Gateway": "",
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "MacAddress": "",
            "Bridge": "",
            "SandboxID": "",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": ""
        },
        "ExitCommand": [
            "/usr/bin/podman",
            "--root",
            "/home/riyad/podman/storage",
            "--runroot",
            "/run/user/1000",
            "--log-level",
            "error",
            "--cgroup-manager",
            "systemd",
            "--tmpdir",
            "/run/user/1000/libpod/tmp",
            "--runtime",
            "crun",
            "--storage-driver",
            "overlay",
            "--storage-opt",
            "overlay.mount_program=/usr/bin/fuse-overlayfs",
            "--storage-opt",
            "overlay.mountopt=nodev",
            "--storage-opt",
            "overlay.mount_program=/usr/bin/fuse-overlayfs",
            "--storage-opt",
            "overlay.mountopt=nodev",
            "--events-backend",
            "journald",
            "container",
            "cleanup",
            "1eff06c0155487862af70a56a61a5ee57c95a7ff1fba28d29513048c8f1d041a"
        ],
        "Namespace": "",
        "IsInfra": false,
        "Config": {
            "Hostname": "1eff06c01554",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "TERM=xterm",
                "container=podman",
                "containers=podman",
                "HOSTNAME="
            ],
            "Cmd": [
                "true"
            ],
            "Image": "docker.io/library/alpine:latest",
            "Volumes": null,
            "WorkingDir": "/",
            "Entrypoint": "",
            "OnBuild": null,
            "Labels": null,
            "Annotations": {
                "io.kubernetes.cri-o.TTY": "false",
                "io.podman.annotations.autoremove": "FALSE",
                "io.podman.annotations.init": "FALSE",
                "io.podman.annotations.privileged": "FALSE",
                "io.podman.annotations.publish-all": "FALSE"
            },
            "StopSignal": 15,
            "CreateCommand": [
                "podman",
                "create",
                "alpine:3.12",
                "true"
            ],
            "Umask": "0022"
        },
        "HostConfig": {
            "Binds": [],
            "CgroupMode": "private",
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "k8s-file",
                "Config": null
            },
            "NetworkMode": "slirp4netns",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": [],
            "CapDrop": [],
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": [],
            "GroupAdd": [],
            "IpcMode": "private",
            "Cgroup": "",
            "Cgroups": "default",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "private",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": [],
            "Tmpfs": {},
            "UTSMode": "private",
            "UsernsMode": "",
            "ShmSize": 65536000,
            "Runtime": "oci",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "user.slice",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": 0,
            "OomKillDisable": false,
            "PidsLimit": 2048,
            "Ulimits": [],
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "CgroupConf": null
        }
    }
]

Test with alpine:3.10

$ podman create alpine:3.10 true 
b485e758afb36063c9f2a9e3bb83ba367a88cea3be76658e3b773678b3635b9c
$ podman inspect b485e758afb36063c9f2a9e3bb83ba367a88cea3be76658e3b773678b3635b9c
[
    {
        "Id": "b485e758afb36063c9f2a9e3bb83ba367a88cea3be76658e3b773678b3635b9c",
        "Created": "2020-12-08T11:45:32.793874959+01:00",
        "Path": "true",
        "Args": [
            "true"
        ],
        "State": {
            "OciVersion": "1.0.2-dev",
            "Status": "configured",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "0001-01-01T00:00:00Z",
            "FinishedAt": "0001-01-01T00:00:00Z",
            "Healthcheck": {
                "Status": "",
                "FailingStreak": 0,
                "Log": null
            }
        },
        "Image": "be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c",
        "ImageName": "docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c",
        "Rootfs": "",
        "Pod": "",
        "ResolvConfPath": "",
        "HostnamePath": "",
        "HostsPath": "",
        "StaticDir": "/home/riyad/podman/storage/overlay-containers/b485e758afb36063c9f2a9e3bb83ba367a88cea3be76658e3b773678b3635b9c/userdata",
        "OCIRuntime": "crun",
        "LogPath": "/home/riyad/podman/storage/overlay-containers/b485e758afb36063c9f2a9e3bb83ba367a88cea3be76658e3b773678b3635b9c/userdata/ctr.log",
        "LogTag": "",
        "ConmonPidFile": "/run/user/1000/overlay-containers/b485e758afb36063c9f2a9e3bb83ba367a88cea3be76658e3b773678b3635b9c/userdata/conmon.pid",
        "Name": "reverent_nightingale",
        "RestartCount": 0,
        "Driver": "overlay",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "EffectiveCaps": [
            "CAP_AUDIT_WRITE",
            "CAP_CHOWN",
            "CAP_DAC_OVERRIDE",
            "CAP_FOWNER",
            "CAP_FSETID",
            "CAP_KILL",
            "CAP_MKNOD",
            "CAP_NET_BIND_SERVICE",
            "CAP_NET_RAW",
            "CAP_SETFCAP",
            "CAP_SETGID",
            "CAP_SETPCAP",
            "CAP_SETUID",
            "CAP_SYS_CHROOT"
        ],
        "BoundingCaps": [
            "CAP_AUDIT_WRITE",
            "CAP_CHOWN",
            "CAP_DAC_OVERRIDE",
            "CAP_FOWNER",
            "CAP_FSETID",
            "CAP_KILL",
            "CAP_MKNOD",
            "CAP_NET_BIND_SERVICE",
            "CAP_NET_RAW",
            "CAP_SETFCAP",
            "CAP_SETGID",
            "CAP_SETPCAP",
            "CAP_SETUID",
            "CAP_SYS_CHROOT"
        ],
        "ExecIDs": [],
        "GraphDriver": {
            "Name": "overlay",
            "Data": {
                "LowerDir": "/home/riyad/podman/storage/overlay/1b3ee35aacca9866b01dd96e870136266bde18006ac2f0d6eb706c798d1fa3c3/diff",
                "UpperDir": "/home/riyad/podman/storage/overlay/993ffbc23b0a85905bc42478e29931935bcf1137c7a1a69032b4e79a0ae7d4f6/diff",
                "WorkDir": "/home/riyad/podman/storage/overlay/993ffbc23b0a85905bc42478e29931935bcf1137c7a1a69032b4e79a0ae7d4f6/work"
            }
        },
        "Mounts": [],
        "Dependencies": [],
        "NetworkSettings": {
            "EndpointID": "",
            "Gateway": "",
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "MacAddress": "",
            "Bridge": "",
            "SandboxID": "",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": ""
        },
        "ExitCommand": [
            "/usr/bin/podman",
            "--root",
            "/home/riyad/podman/storage",
            "--runroot",
            "/run/user/1000",
            "--log-level",
            "error",
            "--cgroup-manager",
            "systemd",
            "--tmpdir",
            "/run/user/1000/libpod/tmp",
            "--runtime",
            "crun",
            "--storage-driver",
            "overlay",
            "--storage-opt",
            "overlay.mount_program=/usr/bin/fuse-overlayfs",
            "--storage-opt",
            "overlay.mountopt=nodev",
            "--storage-opt",
            "overlay.mount_program=/usr/bin/fuse-overlayfs",
            "--storage-opt",
            "overlay.mountopt=nodev",
            "--events-backend",
            "journald",
            "container",
            "cleanup",
            "b485e758afb36063c9f2a9e3bb83ba367a88cea3be76658e3b773678b3635b9c"
        ],
        "Namespace": "",
        "IsInfra": false,
        "Config": {
            "Hostname": "b485e758afb3",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "TERM=xterm",
                "container=podman",
                "containers=podman",
                "HOSTNAME="
            ],
            "Cmd": [
                "true"
            ],
            "Image": "docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c",
            "Volumes": null,
            "WorkingDir": "/",
            "Entrypoint": "",
            "OnBuild": null,
            "Labels": null,
            "Annotations": {
                "io.kubernetes.cri-o.TTY": "false",
                "io.podman.annotations.autoremove": "FALSE",
                "io.podman.annotations.init": "FALSE",
                "io.podman.annotations.privileged": "FALSE",
                "io.podman.annotations.publish-all": "FALSE"
            },
            "StopSignal": 15,
            "CreateCommand": [
                "podman",
                "create",
                "alpine:3.10",
                "true"
            ],
            "Umask": "0022"
        },
        "HostConfig": {
            "Binds": [],
            "CgroupMode": "private",
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "k8s-file",
                "Config": null
            },
            "NetworkMode": "slirp4netns",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": [],
            "CapDrop": [],
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": [],
            "GroupAdd": [],
            "IpcMode": "private",
            "Cgroup": "",
            "Cgroups": "default",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "private",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": [],
            "Tmpfs": {},
            "UTSMode": "private",
            "UsernsMode": "",
            "ShmSize": 65536000,
            "Runtime": "oci",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "user.slice",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": 0,
            "OomKillDisable": false,
            "PidsLimit": 2048,
            "Ulimits": [],
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "CgroupConf": null
        }
    }
]

@riyad riyad changed the title APIv2: wrong image tag is used when creating a container from an image with multiple tags Wrong image tag is used when creating a container from an image with multiple tags Dec 8, 2020
@riyad
Copy link
Contributor Author

riyad commented Dec 8, 2020

Running the examples with Podman 3.0-dev (e2f9120) with the CLI seems to work correctly, but fails when run through the API. 😕

via CLI

$ ./bin/podman create alpine:3.10 true
ce2066b0484d520135402ca4a8060f63988985fd09b005828b6e5341fb6e44e0
$./bin/podman inspect ce2066b0484d520135402ca4a8060f63988985fd09b005828b6e5341fb6e44e0 | jq '.[] .ImageName'
"alpine:3.10"

via API

$ curl -sS --unix-socket /var/run/user/1000/podman/podman.sock -XPOST 'http://localhost/v1.40/containers/create' -H 'Content-Type: application/json' -d '{"Tty": false, "OpenStdin": false, "StdinOnce": false, "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["true"], "Image": "alpine:3.10", "NetworkDisabled": false, "HostConfig": {"NetworkMode": "default"}}'
{"Id":"67c8a4fa2e467cf5958f64087d61ffee37e333f3db86ec35f81a762ebf95a1d5","Warnings":[]}
$ curl -sS --unix-socket /var/run/user/1000/podman/podman.sock -XGET 'http://localhost/v1.40/containers/json?all=1'
[{"Id":"67c8a4fa2e467cf5958f64087d61ffee37e333f3db86ec35f81a762ebf95a1d5","Names":["/compassionate_turing"],"Image":"docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c","ImageID":"be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c","Command":"true","Created":1607425662,"Ports":null,"Labels":{},"State":"created","Status":"","NetworkSettings":null,"Mounts":null,"Name":"","Config":null,"NetworkingConfig":null,"Platform":null,"AdjustCPUShares":false}]

Note the "Image":"docker.io/library/sha256:be4e4bea2c2e15b403bb321562e78ea84b501fb41497472e91ecb41504e8a27c" in the second call.

@riyad
Copy link
Contributor Author

riyad commented Dec 8, 2020

My current summary:

  • Podman 2.1.1 CLI broken
  • Podman 2.1.1 API correct
  • Podman 3.0-dev CLI correct
  • Podman 3.0-dev API broken

@zhangguanzhang
Copy link
Collaborator

zhangguanzhang commented Dec 10, 2020

use the master branch:

$ podman tag docker.io/library/alpine test/alpine
$ ./bin/podman --runtime runc system  service --time 0 tcp:127.0.0.1:8081
$ curl -XPOST 'http://localhost:8081/v1.40/containers/create' \
    -H 'Content-Type: application/json' \
-d '{"Tty": false, "OpenStdin": false, "StdinOnce": false, "AttachStdin": false, "AttachStdout": true, "AttachStderr": truAe, "Cmd": ["true"], "Image": "docker.io/library/alpine", "NetworkDisabled": false, "HostConfig": {"NetworkMode": "default"}}'

{"Id":"fb30671017b8e81e5703049924c2300bf75a84a7cf266df65d4adc9e644578b3","Warnings":[]}
$ curl -s http://localhost:8081/v1.40/containers/json?all=1 | jq .[]
...
{
  "Id": "fb30671017b8e81e5703049924c2300bf75a84a7cf266df65d4adc9e644578b3",
  "Names": [
    "/naughty_villani"
  ],
  "Image": "docker.io/library/alpine:latest",
  "ImageID": "d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0",
  "Command": "true",
  "Created": 1607564603,
  "Ports": null,
  "Labels": {},
  "State": "created",
  "Status": "",
  "NetworkSettings": null,
  "Mounts": null,
  "Name": "",
  "Config": null,
  "NetworkingConfig": null,
  "Platform": null,
  "AdjustCPUShares": false
}

Image is correct

@riyad
Copy link
Contributor Author

riyad commented Dec 10, 2020

Did you try creating the container with the other tag?
I tried this on master just now and it's still broken. 😞
Try creating a container with each of the image tags and see what happens. When I do this it pretends I used the same image name for all containers:

$ ./bin/podman tag docker.io/library/alpine test/alpine 

$ ./bin/podman image ls
REPOSITORY                TAG     IMAGE ID      CREATED       SIZE
docker.io/library/alpine  latest  d6e46aa2470d  7 weeks ago   5.85 MB
docker.io/library/alpine  3.12    d6e46aa2470d  7 weeks ago   5.85 MB
localhost/test/alpine     latest  d6e46aa2470d  7 weeks ago   5.85 MB

$ curl -sS --unix-socket /var/run/user/1000/podman/podman.sock -XPOST 'http://localhost/v1.40/containers/create?name=from_latest' -H 'Content-Type: application/json' -d '{"Tty": false, "OpenStdin": false, "StdinOnce": false, "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["true"], "Image": "alpine", "NetworkDisabled": false, "HostConfig": {"NetworkMode": "default"}}'
{"Id":"670f6d02553d0d6828bf0bc8a10656925a3805e8f746bb6d1e4cd4249dfb3617","Warnings":[]}
$ curl -sS --unix-socket /var/run/user/1000/podman/podman.sock -XPOST 'http://localhost/v1.40/containers/create?name=from_version_tag' -H 'Content-Type: application/json' -d '{"Tty": false, "OpenStdin": false, "StdinOnce": false, "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["true"], "Image": "alpine:3.12", "NetworkDisabled": false, "HostConfig": {"NetworkMode": "default"}}'
{"Id":"7400c9669298c1968b1f4dc2866f1ff8ffd32b49047a39bcdf89d4acd0694f86","Warnings":[]}
$ curl -sS --unix-socket /var/run/user/1000/podman/podman.sock -XPOST 'http://localhost/v1.40/containers/create?name=from_custom_tag' -H 'Content-Type: application/json' -d '{"Tty": false, "OpenStdin": false, "StdinOnce": false, "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["true"], "Image": "test/alpine", "NetworkDisabled": false, "HostConfig": {"NetworkMode": "default"}}'
{"Id":"3871b54e4eadb50926ef78da0b94a852ce13cd43fcfc17275776f5fb0106b2fc","Warnings":[]}


$ ./bin/podman ps -a                       
CONTAINER ID  IMAGE                            COMMAND  CREATED             STATUS   PORTS   NAMES
670f6d02553d  docker.io/library/alpine:latest  true     2 minutes ago       Created          from_latest
7400c9669298  docker.io/library/alpine:latest  true     About a minute ago  Created          from_version_tag
3871b54e4ead  docker.io/library/alpine:latest  true     About a minute ago  Created          from_custom_tag

@zhangguanzhang
Copy link
Collaborator

zhangguanzhang commented Dec 11, 2020

Follow your steps can indeed reproduce, use the localhost/test/alpine will reproduce

$ curl -XPOST 'http://localhost:8081/v1.40/containers/create' -H 'Content-Type: application/json' -d  \
  '{"Tty": false, "OpenStdin": false, "StdinOnce": false, "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["true"], "Image": "localhost/test/alpine", "NetworkDisabled": false, "HostConfig": {"NetworkMode": "default"}}'
{"Id":"310c2fc793bb2bd761417d440805836e7fe48c832938c8824daea0a7f7d3e84b","Warnings":[]}
$ curl -s http://localhost:8081/v1.40/containers/json?all=1 | jq .[]
...
"Id": "310c2fc793bb2bd761417d440805836e7fe48c832938c8824daea0a7f7d3e84b",
  "Names": [
    "/blissful_sutherland"
  ],
  "Image": "docker.io/library/alpine:latest",
  "ImageID": "d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0",

@zhangguanzhang
Copy link
Collaborator

/assign @zhangguanzhang

@riyad
Copy link
Contributor Author

riyad commented Dec 12, 2020

Awesome, thank you for the fix. 😄

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
3 participants