How to setup podman container in already created bridge

I have a bridge device that all of my VM are using to stay in the host network as if they were connected to the router of the network, how can I make that podman container is connected use the same bridge to get the same results?

@Misekayek0l Hi, a peruse here should help https://github.com/containers/podman/blob/main/docs/tutorials/basic_networking.md

@Misekayek0l A quick test;

:~> podman network create -d macvlan -o parent=br0 -o mode=passthru newnet
newnet

:~> podman network inspect newnet

[
     {
          "name": "newnet",
          "id": "884e74728f045cb5209bbaf5e5cf35f1ab7640b11e74ec988fc08ddf97575cf7",
          "driver": "macvlan",
          "network_interface": "br0",
          "created": "2024-01-30T19:30:47.083570055-06:00",
          "ipv6_enabled": false,
          "internal": false,
          "dns_enabled": false,
          "options": {
               "mode": "passthru"
          },
          "ipam_options": {
               "driver": "dhcp"
          }
     }
]

:~> podman network remove newnet
newnet

:~> podman network create -d macvlan -o parent=br3 -o mode=passthru newnet
Error: parent interface br3 does not exist

I have br0 and br1, so br3 errors out as expected…

HAving this two problems:

admin@localhost:~> sudo systemctl enable --now cni-dhcp.socket
Failed to enable unit: Unit file cni-dhcp.socket does not exist.
admin@localhost:~> sudo systemctl enable --now netavark-dhcp-proxy.socket
Failed to enable unit: Unit file netavark-dhcp-proxy.socket does not exist.

Also I commited a mistake this is in micro os not in leap

@Misekayek0l I changed the Tag :wink:

So what does podman info --format {{.Host.NetworkBackend}} show, cni?

So you created the network fine?

admin@localhost:~> sudo podman info --format {{.Host.NetworkBackend}}
cni
admin@localhost:~> sudo podman network create -d macvlan -o parent=bridge0 -o mode=passthru podnet
podnet
admin@localhost:~> echo $?
0

And I am gettings this error:

admin@localhost:~> sudo podman run -it --rm --net=podnet alpine sh
WARN[0000] Failed to load cached network config: network podnet not found in CNI cache, falling back to loading network podnet from disk 
WARN[0000] 1 error occurred:
                                * plugin type="macvlan" failed (delete): cni plugin macvlan failed: error dialing DHCP daemon: dial unix /run/cni/dhcp.sock: connect: no such file or directory
                                                                                            
Error: plugin type="macvlan" failed (add): cni plugin macvlan failed: error dialing DHCP daemon: dial unix /run/cni/dhcp.sock: connect: no such file or directory

@Misekayek0l Run the dhcp daemon…

sudo /usr/libexec/cni/dhcp daemon &
admin@localhost:~> sudo /usr/libexec/cni/dhcp daemon &
[1] 2775
admin@localhost:~> jobs 
[1]+  Stopped                 sudo /usr/libexec/cni/dhcp daemon
admin@localhost:~> jobs 
[1]+  Stopped                 sudo /usr/libexec/cni/dhcp daemon
admin@localhost:~> sudo podman run -it --rm --net=podnet alpine sh
[sudo] password for root: 
WARN[0001] Failed to load cached network config: network podnet not found in CNI cache, falling back to loading network podnet from disk 
WARN[0001] 1 error occurred:
                                * plugin type="macvlan" failed (delete): cni plugin macvlan failed: error dialing DHCP daemon: dial unix /run/cni/dhcp.sock: connect: no such file or directory
                                                                                            
Error: plugin type="macvlan" failed (add): cni plugin macvlan failed: error dialing DHCP daemon: dial unix /run/cni/dhcp.sock: connect: no such file or directory

@Misekayek0l Hmm all good here on MicroOS…

:~ # /usr/libexec/cni/dhcp daemon &
[1] 4403
:~ # jobs
[1]+  Running                 /usr/libexec/cni/dhcp daemon &
admin@localhost:~/iso> sudo sh
[sudo] password for root: 
sh-4.4# /usr/libexec/cni/dhcp daemon &
[1] 3144
sh-4.4# sh: /usr/libexec/cni/dhcp: No such file or directory
sh-4.4# ls /usr/    
bin  etc  include  lib  lib64  local  sbin  share  src  x86_64-suse-linux

@Misekayek0l Is cni-plugins installed?

transactional-update pkg install cni-plugins
transactional-update apply
admin@localhost:~> sudo transactional-update pkg install cni-plugins
Checking for newer version.
transactional-update 4.1.6 started
Options: pkg install cni-plugins
Separate /var detected.
2024-01-31 05:42:08 tukit 4.1.6 started
2024-01-31 05:42:08 Options: -c86 open 
2024-01-31 05:42:10 Using snapshot 86 as base for new snapshot 87.
2024-01-31 05:42:10 /var/lib/overlay/86/etc
2024-01-31 05:42:10 Syncing /etc of previous snapshot 85 as base into new snapshot "/.snapshots/87/snapshot"
2024-01-31 05:42:10 SELinux is enabled.
ID: 87
2024-01-31 05:42:14 Transaction completed.
Calling zypper install
zypper: nothing to update
Removing snapshot #87...
2024-01-31 05:42:18 tukit 4.1.6 started
2024-01-31 05:42:18 Options: abort 87 
2024-01-31 05:42:21 Discarding snapshot 87.
2024-01-31 05:42:21 Transaction completed.
transactional-update finished
admin@localhost:~> sudo ls /usr/libexec/cni/dhcp
ls: cannot access '/usr/libexec/cni/dhcp': No such file or directory

Aditionally:

admin@localhost:~> zypper se --provides /usr/libexec/cni/dhcp
Loading repository data...
Reading installed packages...
No matching items found.

    Note: For an extended search including not yet activated remote resources please use 'zypper
    search-packages'.
admin@localhost:~> zypper search-packages --provides /usr/libexec/cni/dhcp
Cannot perform extended package search:

Extended search does not support search by dependencies.
'/usr/lib/zypper/commands/zypper-search-packages' exited with status 1

@Misekayek0l

zypper se --provides "/usr/libexec/cni/dhcp"
Loading repository data...
Reading installed packages...

S | Name        | Summary                             | Type
--+-------------+-------------------------------------+--------
i | cni-plugins | Container Network Interface plugins | package

:~ # ls /usr/libexec/cni/dhcp
/usr/libexec/cni/dhcp

Line 15 https://build.opensuse.org/package/view_file/openSUSE:Factory/cni-plugins/cni-plugins.spec?expand=1

In general it wonly works for installed packages. Only binaries (files under /bin or /usr/bin) are automatically added to package provides, other files need to be manually listed in spec.

@arvidjaar I did wonder, but the user indicates it’s (cni-plugins) installed, but not there…

Where? I must have missed it.

Educated guess - it is installed in the inactive snapshot.