containers / podman-compose

a script to run docker-compose.yml using podman
GNU General Public License v2.0
5.01k stars 477 forks source link

network ipam: podman fails when driver is set to "default" #852

Closed fccagou closed 5 months ago

fccagou commented 7 months ago

Describe the bug""

if ipam driver set to "default" in compose file, podman-compose run podman network command with --ipam-driver default and the command fails.

To Reproduce

Create simple docker-compose.yml containing

version: "3"
services:
    web1:
      image: busybox
      hostname: web1
      command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
      working_dir: /var/www/html
      ports:
        - 8001:8001
      volumes:
        - ./test1.txt:/var/www/html/index.txt:ro,z
      networks:
        test4:

networks:
  test4:
    driver: bridge
    ipam:
      driver: default
      config:
          - subnet: 10.99.99.0/24

Then run podman-compose up

Expected behavior

Creates nets_test4 network.

Actual behavior

Fails with exception.

When running command by hand

podman network create --label io.podman.compose.project=nets_test4 --label com.docker.compose.project=nets_test4 --driver bridge --ipam-driver default --subnet 10.99.99.0/24 nets_test4_test4
Error: unsupported ipam driver "default"

Output

podman-compose version: 1.0.7
['podman', '--version', '']
using podman version: 4.9.3
** excluding:  set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=nets_test4', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
podman pod create --name=pod_nets_test4 --infra=false --share=
Error: adding pod to state: name "pod_nets_test4" is in use: pod already exists
exit code: 125
['podman', 'network', 'exists', 'nets_test4_test4']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=nets_test4', '--label', 'com.docker.compose.project=nets_test4', '--driver', 'bridge', '--ipam-driver', 'default', '--subnet', '10.99.99.0/24', 'nets_test4_test4']
Traceback (most recent call last):
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 738, in assert_cnt_nets
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 1183, in output
subprocess.CalledProcessError: Command 'podman network exists nets_test4_test4' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fccagou/src/podman-compose/venv/bin/podman-compose", line 33, in <module>
    sys.exit(load_entry_point('podman-compose==1.0.7', 'console_scripts', 'podman-compose')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 3246, in main
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 3243, in async_main
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 1555, in run
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 2288, in compose_up
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 962, in container_to_args
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 781, in assert_cnt_nets
  File "/home/fccagou/src/podman-compose/venv/lib/python3.11/site-packages/podman_compose-1.0.7-py3.11.egg/podman_compose.py", line 1183, in output
subprocess.CalledProcessError: Command 'podman network create --label io.podman.compose.project=nets_test4 --label com.docker.compose.project=nets_test4 --driver bridge --ipam-driver default --subnet 10.99.99.0/24 nets_test4_test4' returned non-zero exit status 125.

Environment:

Additional context

Add any other context about the problem here.