containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.83k stars 2.42k forks source link

podman inspect network doesn't include running containers #14126

Closed ChrisBr closed 8 months ago

ChrisBr commented 2 years ago

/kind bug

Description

podman network inspect doesn't include containers using the network

Steps to reproduce the issue:

  1. Create network podman network create

  2. Start container podman run -it --network podman1 alpine

  3. Inspect network podman inspect podman1

Describe the results you received:

podman inspect podman1 does not contain a list of containers using the network.

Describe the results you expected:

Same command in docker contains a list of containers.

"Containers": {
  "bb522a1964c46b2970aa825cafce1bf2e971e195ad5b9784bb5bd13d53737e9d": {
      "Name": "elated_montalcini",
      "EndpointID": "08397fd8bb4e9c80a37b2bfb8f259c23181374dac2a0e1febcffcdc4d89bc32c",
      "MacAddress": "02:42:ac:1b:00:02",
      "IPv4Address": "172.27.0.2/16",
       "IPv6Address": ""
  }
}

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

Output of podman version:

Client:       Podman Engine
Version:      4.0.3
API Version:  4.0.3
Go Version:   go1.18
Built:        Fri Apr  1 16:28:59 2022
OS/Arch:      darwin/arm64

Server:       Podman Engine
Version:      4.0.3
API Version:  4.0.3
Go Version:   go1.18
Built:        Fri Apr  1 19:22:39 2022
OS/Arch:      linux/arm64

Output of podman info --debug:

host:
  arch: arm64
  buildahVersion: 1.24.3
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - pids
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.0-2.fc36.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.0, commit: '
  cpus: 4
  distribution:
    distribution: fedora
    variant: coreos
    version: "36"
  eventLogger: journald
  hostname: localhost.localdomain
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 5.17.3-300.fc36.aarch64
  linkmode: dynamic
  logDriver: journald
  memFree: 7293345792
  memTotal: 8304160768
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.4.4-1.fc36.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.4.4
      commit: 6521fcc5806f20f6187eb933f9f45130c86da230
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/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: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.0-0.2.beta.0.fc36.aarch64
    version: |-
      slirp4netns version 1.2.0-beta.0
      commit: 477db14a24ff1a3de3a705e51ca2c4c1fe3dda64
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.3
  swapFree: 0
  swapTotal: 0
  uptime: 3h 25m 5.43s (Approximately 0.12 days)
plugins:
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 0
    stopped: 2
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 9
  runRoot: /run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 4.0.3
  Built: 1648837359
  BuiltTime: Fri Apr  1 19:22:39 2022
  GitCommit: ""
  GoVersion: go1.18
  OsArch: linux/arm64
  Version: 4.0.3

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

brew info podman
podman: stable 4.0.3 (bottled), HEAD
Tool for managing OCI containers and pods
https://podman.io/
/opt/homebrew/Cellar/podman/4.0.3 (172 files, 46.2MB) *
  Poured from bottle on 2022-05-05 at 08:20:47
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/podman.rb
License: Apache-2.0
==> Dependencies
Build: go ✔, go-md2man ✘
Required: qemu ✔
==> Options
--HEAD
    Install HEAD version
==> Caveats
zsh completions have been installed to:
  /opt/homebrew/share/zsh/site-functions
==> Analytics
install: 17,297 (30 days), 48,514 (90 days), 131,788 (365 days)
install-on-request: 17,297 (30 days), 48,499 (90 days), 131,766 (365 days)
build-error: 1 (30 days)

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

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

Macbook M1 installed with homebrew

Luap99 commented 2 years ago

@baude I think you looked at this before?

I am not the biggest fan of adding this to the network inspect output. The current network inspect output is not docker compatible at all, there are just a lot of different things in the podman/docker network stack. Also your example output structure would not work because you can have more than ipv4 and ipv6 address per network. I also have no clue what the EndpointID is, is it the network ID?

You can get docker compatible output via the API. Although I am not sure if this is correctly implement there.

rhatdan commented 2 years ago

The question I have, Is it useful to a user to figure out which containers are using a particular network?

Luap99 commented 2 years ago

The question I have, Is it useful to a user to figure out which containers are using a particular network?

You can get this with podman ps --filter network=name

rhatdan commented 2 years ago

Ok, as long as that is easy to retrieve, I don't see the compatibility as that big of an issue.

baude commented 2 years ago

this is a duplicate of a jira card i was working on. the code is done but the problem is that would be a breaking change on output. we discussed podman 5, but i also would like to go back and look at things to see if i can weasel it in without breaking changes.

ChrisBr commented 2 years ago

You can get this with podman ps --filter network=name

~Our use case is that we have like 70-80 containers running and we need to find which ones are in the same network.~

ChrisBr commented 2 years ago

podman ps --filter network=name

This would work but would break compatibility with docker (which I understand is not a big concern for you).

baude commented 2 years ago

we really do try on the compatibility stuff. in this case, the easy button just won't work ... but if you look at my update, i committed to trying it a different way. I have the code all written and it works, so not far away.

github-actions[bot] commented 2 years ago

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

rhatdan commented 2 years ago

@baude what is the state of this one now?

baude commented 2 years ago

feel victim to other priorities. will try to pick back up soon,

github-actions[bot] commented 2 years ago

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

rhatdan commented 2 years ago

@Luap99 PTAL

github-actions[bot] commented 2 years ago

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

rhatdan commented 2 years ago

@baude @Luap99 @flouthoc PTAL

github-actions[bot] commented 2 years ago

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

rhatdan commented 2 years ago

@baude @Luap99 @flouthoc @mheon re-ping

baude commented 2 years ago

cannot be done until podman 5

rhatdan commented 2 years ago

Sorry I missed that. Wish there was a way to stop the reminder on issues waiting for podman 5.