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

Docker compatibility: Container Inspect returns null for NetworkSettings.Networks #9837

Closed
candrews opened this issue Mar 26, 2021 · 5 comments · Fixed by #10206
Closed

Docker compatibility: Container Inspect returns null for NetworkSettings.Networks #9837

candrews opened this issue Mar 26, 2021 · 5 comments · Fixed by #10206
Assignees
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. 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

@candrews
Copy link

candrews commented Mar 26, 2021

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

The result of the ImageInspect API request:
GET /v1.30/images/curlimages%2Fcurl:latest/json
has NetworkSettings.Networks set to "null". That should not be the case. See https://docs.docker.com/engine/api/v1.30/#operation/ContainerInspect

Example docker API request: GET /v1.30/containers/7d6274e7015544739788b479d4d05a49e452a6e5c24a9e788c0e580b40524a21/json

And response:

{"Id":"7d6274e7015544739788b479d4d05a49e452a6e5c24a9e788c0e580b40524a21","Created":"2021-03-26T18:58:12.472132588-04:00","Path":"sh","Args":["-c","echo \\"root:$PASSWORD\\" | chpasswd \\u0026\\u0026 /usr/sbin/sshd -D -o PermitRootLogin=yes -o AddressFamily=inet -o GatewayPorts=yes"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":1144251,"ExitCode":0,"Error":"","StartedAt":"2021-03-26T18:58:12.831990779-04:00","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"docker.io/testcontainers/sshd:1.0.0","ResolvConfPath":"/run/user/1000/overlay-containers/7d6274e7015544739788b479d4d05a49e452a6e5c24a9e788c0e580b40524a21/userdata/resolv.conf","HostnamePath":"/run/user/1000/overlay-containers/7d6274e7015544739788b479d4d05a49e452a6e5c24a9e788c0e580b40524a21/userdata/hostname","HostsPath":"/run/user/1000/overlay-containers/7d6274e7015544739788b479d4d05a49e452a6e5c24a9e788c0e580b40524a21/userdata/hosts","LogPath":"/home/candrews/.local/share/containers/storage/overlay-containers/7d6274e7015544739788b479d4d05a49e452a6e5c24a9e788c0e580b40524a21/userdata/ctr.log","Name":"/jovial_kowalevski","RestartCount":0,"Driver":"overlay","Platform":"linux","MountLabel":"system_u:object_r:container_file_t:s0:c792,c808","ProcessLabel":"system_u:system_r:container_t:s0:c792,c808","AppArmorProfile":"","ExecIDs":[],"HostConfig":{"Binds":[],"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":null},"NetworkMode":"slirp4netns","PortBindings":{"22/tcp":[{"HostIp":"","HostPort":"38423"}]},"RestartPolicy":{"Name":"","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"CapAdd":[],"CapDrop":["AUDIT_WRITE","MKNOD","NET_RAW"],"CgroupnsMode":"","Dns":[],"DnsOptions":[],"DnsSearch":[],"ExtraHosts":[],"GroupAdd":[],"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"private","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":[],"UTSMode":"private","UsernsMode":"","ShmSize":65536000,"Runtime":"oci","ConsoleSize":[0,0],"Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":null,"BlkioDeviceReadBps":null,"BlkioDeviceWriteBps":null,"BlkioDeviceReadIOps":null,"BlkioDeviceWriteIOps":null,"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"KernelMemory":0,"KernelMemoryTCP":0,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":0,"OomKillDisable":false,"PidsLimit":0,"Ulimits":[],"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":null,"ReadonlyPaths":null},"GraphDriver":{"Data":{"LowerDir":"/home/candrews/.local/share/containers/storage/overlay/802b211bfc74359439a1f8383eb0fe7a14184a54bad35386832f753be750fdcb/diff:/home/candrews/.local/share/containers/storage/overlay/f566c57e6f2da2364c14195c832b922fd8f4813fd139b8fe45e3454c16e33975/diff","MergedDir":"/home/candrews/.local/share/containers/storage/overlay/7bd84c35dd88d4ef0a360a162fee9b69d4eb124e0c1156e13e51c8dc5ba515de/merged","UpperDir":"/home/candrews/.local/share/containers/storage/overlay/7bd84c35dd88d4ef0a360a162fee9b69d4eb124e0c1156e13e51c8dc5ba515de/diff","WorkDir":"/home/candrews/.local/share/containers/storage/overlay/7bd84c35dd88d4ef0a360a162fee9b69d4eb124e0c1156e13e51c8dc5ba515de/work"},"Name":"overlay"},"SizeRootFs":0,"Mounts":[],"Config":{"Hostname":"7d6274e70155","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"22/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","TERM=xterm","container=podman","PASSWORD=01a30825-802d-4342-82f5-80b328b18343","HOME=/root","HOSTNAME=7d6274e70155"],"Cmd":["sh","-c","echo \\"root:$PASSWORD\\" | chpasswd \\u0026\\u0026 /usr/sbin/sshd -D -o PermitRootLogin=yes -o AddressFamily=inet -o GatewayPorts=yes"],"Image":"docker.io/testcontainers/sshd:1.0.0","Volumes":null,"WorkingDir":"/","Entrypoint":[],"OnBuild":null,"Labels":{"org.testcontainers":"true","org.testcontainers.sessionId":"a122b30f-c78b-462f-a9dd-6e9e87650d4a"},"StopSignal":"15","StopTimeout":0},"NetworkSettings":{"Bridge":"","SandboxID":"","HairpinMode":false,"LinkLocalIPv6Address":"","LinkLocalIPv6PrefixLen":0,"Ports":{"22/tcp":[{"HostIp":"","HostPort":"38423"}]},"SandboxKey":"/run/user/1000/netns/cni-f86e1703-0342-1c69-394d-045584856f96","SecondaryIPAddresses":null,"SecondaryIPv6Addresses":null,"EndpointID":"","Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"IPAddress":"","IPPrefixLen":0,"IPv6Gateway":"","MacAddress":"","Networks":null}}

Note the "Networks":null in that response.

This results in an issue when using testcontainers, Testcontainers.exposeHostPorts results in an exception:
Cannot invoke "java.util.Map.values()" because the return value of "com.github.dockerjava.api.model.NetworkSettings.getNetworks()" is null

Here's socat output of the docker socket communication, captured by running: socat -v UNIX-LISTEN:/tmp/fake,fork UNIX-CONNECT:/run/user/1000/podman/podman.sock
socat-docker-socket.log

Steps to reproduce the issue:

I reproduced the issue by running testcontainers using the information provided at testcontainers/testcontainers-java#3934

Describe the results you received:
NetworkSettings.Networks is returned as null

Describe the results you expected:
NetworkSettings.Networks is populated

Additional information you deem important (e.g. issue happens only occasionally):
Discovered when using testcontainers: testcontainers/testcontainers-java#3934

Output of podman version:

podman version 3.1.0-rc2

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.19.8
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: conmon-2.0.27-1.fc34.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.27, commit: '
  cpus: 8
  distribution:
    distribution: fedora
    version: "34"
  eventLogger: journald
  hostname: craigatwork
  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.11.8-300.fc34.x86_64
  linkmode: dynamic
  memFree: 3268112384
  memTotal: 16647507968
  ociRuntime:
    name: crun
    package: crun-0.18-1.fc34.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 0.18
      commit: 808420efe3dc2b44d6db9f1a3fac8361dde42a95
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  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
    selinuxEnabled: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.1.9-1.fc34.x86_64
    version: |-
      slirp4netns version 1.1.8+dev
      commit: 6dc0186e020232ae1a6fcc1f7afbc3ea02fd3876
      libslirp: 4.4.0
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.0
  swapFree: 8108294144
  swapTotal: 16924008448
  uptime: 81h 25m 28.88s (Approximately 3.38 days)
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/candrews/.config/containers/storage.conf
  containerStore:
    number: 9
    paused: 0
    running: 7
    stopped: 2
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: fuse-overlayfs-1.4.0-3.fc34.x86_64
      Version: |-
        fusermount3 version: 3.10.2
        fuse-overlayfs: version 1.4
        FUSE library version 3.10.2
        using FUSE kernel interface version 7.31
  graphRoot: /home/candrews/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 10
  runRoot: /run/user/1000
  volumePath: /home/candrews/.local/share/containers/storage/volumes
version:
  APIVersion: 3.1.0-rc2
  Built: 1616550335
  BuiltTime: Tue Mar 23 21:45:35 2021
  GitCommit: ""
  GoVersion: go1.16
  OsArch: linux/amd64
  Version: 3.1.0-rc2

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

podman-3.1.0-0.2.rc2.fc34.x86_64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

physical

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 26, 2021
@candrews
Copy link
Author

candrews commented Mar 26, 2021

This issue appears to be related to #6803

NetworkSettings.Networks was set to nil in https://github.com/containers/podman/pull/6852/files#diff-00600f2049a889a68d02d52f0b7f8a3b5dfcd9e9ba4499b66fa830f56f0dc3b1R401

@candrews candrews changed the title Docker compatibility: Error using Testcontainers.exposeHostPorts Docker compatibility: Container Inspect returns null for NetworkSettings.Networks Mar 26, 2021
@rhatdan
Copy link
Member

rhatdan commented Mar 27, 2021

Care to open a PR to attempt to fix this?

@candrews
Copy link
Author

Care to open a PR to attempt to fix this?

I really want to, and started to look into doing so... but it's a lot to learn. I don't entirely understand what many of the Networks data structure fields are, and those that I do understand, I can't figure out where/how to get that data in podman.

@github-actions
Copy link

github-actions bot commented May 1, 2021

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented May 3, 2021

@Luap99 Care to look at this one?

@rhatdan rhatdan added Good First Issue This issue would be a good issue for a first time contributor to undertake. and removed stale-issue labels May 3, 2021
@Luap99 Luap99 self-assigned this May 4, 2021
Luap99 pushed a commit to Luap99/libpod that referenced this issue May 4, 2021
The compat endpoint for container inspect must return {} instead of null
for NetworkSettings.Networks.

Fixes containers#9837

Signed-off-by: Paul Holzinger <[email protected]>
@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
Good First Issue This issue would be a good issue for a first time contributor to undertake. 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
Development

Successfully merging a pull request may close this issue.

4 participants