podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

With multiple networks: Unable to specify per-network static ip addresses

Open tchernobog opened this issue 2 years ago • 1 comments

When attempting to run a service with multiple networks, each with a static IP address, podman is incorrectly invoked with multiple --ip parameters.

It should instead use --network <name>:ip=<ip>. This problem might possibly extend to other per-network options, such as mac addresses to use.

To Reproduce

Example compose.yml:

version: "3.8"
services:
  hello-world:
    image: docker.io/hello-world:latest
    tty: true
    stdin_open: true
    networks:
      net0:
      net1:
        ipv4_address: 192.168.72.2
      net2:
        ipv4_address: 192.168.72.34

networks:
  net0:
    driver: bridge

  net1:
    driver: ipvlan
    ipam:
      config:
        - subnet: 192.168.72.0/27

  net2:
    driver: ipvlan
    ipam:
      config:
        - subnet: 192.168.72.32/27

Expected behavior

podman create succeeds as it is invoked with --net podman-compose-net-bug_net0 --net podman-compose-net-bug_net1:ip=192.168.72.2 --net podman-compose-net-bug_net2:ip=192.168.72.34

Actual behavior

podman create fails because instead --ip is provided multiple times, but is not associated to the relevant network.

Output

$ podman-compose version

podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.7.2
podman-compose version 1.0.6
podman --version 
podman version 4.7.2
exit code: 0

$ podman-compose up

podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.7.2
** excluding:  set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=podman-compose-net-bug', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'podman-compose-net-bug_net0']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=podman-compose-net-bug', '--label', 'com.docker.compose.project=podman-compose-net-bug', '--driver', 'bridge', 'podman-compose-net-bug_net0']
['podman', 'network', 'exists', 'podman-compose-net-bug_net0']
['podman', 'network', 'exists', 'podman-compose-net-bug_net1']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=podman-compose-net-bug', '--label', 'com.docker.compose.project=podman-compose-net-bug', '--driver', 'ipvlan', '--subnet', '192.168.72.0/27',
 '--gateway', '192.168.72.1', 'podman-compose-net-bug_net1']
['podman', 'network', 'exists', 'podman-compose-net-bug_net1']
['podman', 'network', 'exists', 'podman-compose-net-bug_net2']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=podman-compose-net-bug', '--label', 'com.docker.compose.project=podman-compose-net-bug', '--driver', 'ipvlan', '--subnet', '192.168.72.32/27'
, '--gateway', '192.168.72.33', 'podman-compose-net-bug_net2']
['podman', 'network', 'exists', 'podman-compose-net-bug_net2']
podman create --name=podman-compose-net-bug_hello-world_1 --label io.podman.compose.config-hash=7545ab99bc6998d28cd4d6061a44cada39f13dbe3a3643f49abfe5d82f56d34d --label io.podman.compose.project=podman-compose-n
et-bug --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@podman-compose-net-bug.service --label com.docker.compose.project=podman-compose-net-bug --label com.docker.compose.proje
ct.working_dir=/home/matteo/podman-compose-net-bug --label com.docker.compose.project.config_files=compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=hello-world --net p
odman-compose-net-bug_net2,podman-compose-net-bug_net1,podman-compose-net-bug_net0 --network-alias hello-world --ip=192.168.72.2 -i --tty docker.io/hello-world:latest
Error: --ip can only be set for a single network: invalid argument
exit code: 125
podman start -a podman-compose-net-bug_hello-world_1
Error: no container with name or ID "podman-compose-net-bug_hello-world_1" found: no such container
exit code: 125

Environment:

  • OS: Linux
  • podman version: 4.7.2
  • podman compose version: 1.0.6

tchernobog avatar Dec 15 '23 14:12 tchernobog

Does this project dead? Why is its bug fixing so slow and release times very few? That seems like it can't instead of docker-compose.

WowYouCanReallyDance avatar Jan 29 '24 13:01 WowYouCanReallyDance

This seems to be fixed in devel already

baszoetekouw avatar Feb 29 '24 20:02 baszoetekouw

Not all of it, seemingly, so I've created a PR that should solve all of it.

baszoetekouw avatar Mar 07 '24 13:03 baszoetekouw