containers / podman-compose

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

Podman-compose is not handling networks: RuntimeError: missing networks: #463

Open Reizake opened 2 years ago

Reizake commented 2 years ago

When trying to make a static IP setting based specifically on this documentation under the "ipv4_address, ipv6_address" section: https://docs.docker.com/compose/compose-file/compose-file-v3/

I am receiving the "RuntimeError: missing networks: default,podman" error. I have tried a variety of other methods to no avail. it seems that podman-compose is not properly reading the networks: section in the yaml

here is my compose file:

version: '3'

networks:
  default:
    external:
      name: podman
  podman:
    ipam:
      driver: default
      config:
        - subnet: "10.88.2.0/24"

services:

  app:
    image: nextcloud
    restart: always
    volumes:
      - ./nextcloud:/var/www/html 
    environment:
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx
      - MYSQL_HOST=xxxx
    networks:
      podman:
           ipv4_address:10.88.2.10

  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxxx
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx
    networks:
     podman:
          ipv4_address:10.88.2.11

And here are the results I get:

User@Computer:/DAS/PodmanVolumes/nextcloud$ sudo podman-compose  up -d
['podman', '--version', '']
using podman version: 3.2.1
Traceback (most recent call last):
  File "/usr/local/bin/podman-compose", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/podman_compose.py", line 1775, in main
    podman_compose.run()
  File "/usr/local/lib/python3.9/dist-packages/podman_compose.py", line 1022, in run
    self._parse_compose_file()
  File "/usr/local/lib/python3.9/dist-packages/podman_compose.py", line 1128, in _parse_compose_file
    raise RuntimeError(f"missing networks: {missing_nets_str}")
RuntimeError: missing networks: default,podman

I have tried using default as well as "network_mode" neither gave good results. please let me know if there is any other info needed or things you would like me to try.

muayyad-alsadi commented 2 years ago

Question?

what version of podman-compose are you using?

NOTE

the external part in networks mean you need to manage it yourself, you should create this network, see compose spec

here is an example how to specify static ip

version: "3"
networks:
  app1_container_network:
    ipam:
      driver: default
      config:
        - subnet: "172.20.0.0/16"
services:
  app1:
    image: busybox
    command: httpd -f -p 8080 -h /etc/
    networks:
      app1_container_network:
        ipv4_address: 172.20.0.11

NOTE 2

specifying address is against the 12 factor you should use port mapping not ip address mapping.

Reizake commented 2 years ago

I am running:

['podman', '--version', '']
using podman version: 3.2.1
podman-composer version  1.0.3
podman --version 
podman version 3.2.1
exit code: 0

just to confirm. this will still put it in the pre-existing network "podman" correct?

Either way when I set my compose file as such:

version: '3'

networks:
  podman:
    ipam:
      driver: default
      config:
        - subnet: "10.88.2.0/24"

services:

  app:
    image: nextcloud
    restart: always
    volumes:
      - ./nextcloud:/var/www/html 
    environment:
      - MYSQL_PASSWORD=xxxx
      - MYSQL_USER=xxxx
      - MYSQL_HOST=xxxx
    networks:
       podman:
           ipv4_address:10.88.2.10

  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxxx
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx
    networks:
       podman:
          ipv4_address:10.88.2.11

it still spits this error:

user@computer:/DAS/PodmanVolumes/nextcloud$ sudo podman-compose  up -d
['podman', '--version', '']
using podman version: 3.2.1
Traceback (most recent call last):
  File "/usr/local/bin/podman-compose", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/podman_compose.py", line 1775, in main
    podman_compose.run()
  File "/usr/local/lib/python3.9/dist-packages/podman_compose.py", line 1022, in run
    self._parse_compose_file()
  File "/usr/local/lib/python3.9/dist-packages/podman_compose.py", line 1128, in _parse_compose_file
    raise RuntimeError(f"missing networks: {missing_nets_str}")
RuntimeError: missing networks: podman
muayyad-alsadi commented 2 years ago

would you please try latest branch.

pip3 install https://github.com/containers/podman-compose/archive/devel.tar.gz

I've tested it with equivalent yaml and it worked

---
version: "3"
networks:
  podman:
    ipam:
      driver: default
      config:
        - subnet: "10.88.2.0/24"
services:
  web1:
    image: busybox
    command: httpd -f -p 8080 -h /etc/
    networks:
      podman:
        ipv4_address: 10.88.2.10
  web2:
    image: busybox
    command: httpd -f -p 8080 -h /etc/
    networks:
      podman:
        ipv4_address: 10.88.2.11
Reizake commented 2 years ago

updating to the newest version fixed it. just for reference when wanting to use a pre-existing network you can ley it out as such:

networks:
  podman:
    external:
      name: podman

services:

  app:
    image: nextcloud
    restart: always
    volumes:
      - ./nextcloud:/var/www/html 
    environment:
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx
      - MYSQL_HOST=xxxx
    networks:
       podman:
         ipv4_address: 10.88.2.10
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxxx
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx
    networks:
        podman:
          ipv4_address: 10.88.2.11

I also notice it puts my containers in a pod now, which I like, but is there a command to stop that from happening in the compose file. or just a general way of setting pod configuration?

muayyad-alsadi commented 2 years ago

, but is there a command to stop that from happening in the compose file. or just a general way of setting pod configuration?

to prevent creating a pod

  --no-pod              disable pod creation

to adjust pod params

  --pod-args pod_args   disable pod creation

there is no way to control that from inside the yaml

jave commented 2 years ago

Just a note that upgrading to podman-compose 1.0.4 fixed the same problem for me

mchoeti commented 1 year ago

there is no way to control that from inside the yaml Hm... but doing this podman-compose up --no-pod

results in unrecognized arguments: --no-pod

Do you have an example?

dpward commented 1 year ago

updating to the newest version fixed it.

For those finding this online and looking to backport a patch: the issue originally described here was #399, which was fixed with 4aa08cd0168de07641832d31b58b8f29eecfd059.

bigon commented 1 year ago

Any plan to do a new release?

midu16 commented 1 year ago

@muayyad-alsadi is there any plan on the podman-compose 1.0.4 rpm release? Fedora 37 is still using the 1.0.3.

mreiche commented 1 year ago

I'm facing the same issue with newer versions:

podman-compose --version

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

 Error tearing down partially created network namespace for container c43...c48: CNI network "my_bridge" not found

The network itself was created and exists:

podman network ls

WARN[0000] Error validating CNI config file /etc/cni/net.d/my_bridge.conflist: [plugin bridge does not support config version "1.0.0" plugin portmap does not support config version "1.0.0" plugin firewall does not support config version "1.0.0" plugin tuning does not support config version "1.0.0"]
NETWORK ID    NAME           VERSION     PLUGINS
2f259bab93aa  podman         0.4.0       bridge,portmap,firewall,tuning
177b12cc34e2  my_bridge  1.0.0       bridge,portmap,firewall,tuning,dnsname

Edit: It only works when I use the preconfigured bridge network podman.

networks:
  my_bridge:
    external:
      name: podman
Antoniossss commented 1 year ago

Having the exact same issue as @mreiche here. Any ideas??

mreiche commented 1 year ago

Having the exact same issue as @mreiche here. Any ideas??

I use podman network instead. So you could configure a network manually and reference it as external in your compose file.

mreiche commented 9 months ago

I came back to this, because my problem seems to be related to Podman 3.4.4 on Ubuntu 22.04 and there is no official newer version available and I need to get this fixed. So this is my workaround.

When I created an external network, I saw a list with different versions.

podman network ls
NETWORK ID    NAME        VERSION     PLUGINS
2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning
8ac92e008a0e  my_network  1.0.0       bridge,portmap,firewall,tuning,dnsname

and a suspicious message:

WARN[0000] Error validating CNI config file /etc/cni/net.d/my_network.conflist: [plugin bridge does not support config version "1.0.0" plugin portmap does not support config version "1.0.0" plugin firewall does not support config version "1.0.0" plugin tuning does not support config version "1.0.0"]

So I edited /etc/cni/net.d/my_network.conflist and changed the version to 0.4.0.

podman network ls
NETWORK ID    NAME        VERSION     PLUGINS
2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning
8ac92e008a0e  my_network  0.4.0       bridge,portmap,firewall,tuning,dnsname

This network I could use with podman-compose like:

networks:
  default:
    name: my_network
    external: true

where also DNS resolution works now.

Antoniossss commented 9 months ago

Is that a fix or a way to mute version compatibility warnings?

sob., 27 sty 2024, 20:09 użytkownik Mike Reiche @.***> napisał:

I came back to this, because my problem seems to be related to Podman 3.4.4 on Ubuntu 22.04, because there is no official newer version available and I need to get this fixed. So this is my workarround.

When I created an external network, I saw a list with different versions.

podman network ls NETWORK ID NAME VERSION PLUGINS 2f259bab93aa podman 0.4.0 bridge,portmap,firewall,tuning 8ac92e008a0e my_network 1.0.0 bridge,portmap,firewall,tuning,dnsname

and a suspicious message: ´´´ WARN[0000] Error validating CNI config file /etc/cni/net.d/my_network.conflist: [plugin bridge does not support config version "1.0.0" plugin portmap does not support config version "1.0.0" plugin firewall does not support config version "1.0.0" plugin tuning does not support config version "1.0.0"]

So I edited /etc/cni/net.d/my_network.conflist and changed the version to 0.4.0.


podman network ls
NETWORK ID    NAME        VERSION     PLUGINS
2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning
8ac92e008a0e  my_network  0.4.0       bridge,portmap,firewall,tuning,dnsname

This network I could use with podman-compose like:

networks:
  default:
    name: my_network
    external: true´´´where also DNS resolution works now.

—
Reply to this email directly, view it on GitHub
<https://github.com/containers/podman-compose/issues/463#issuecomment-1913298533>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB4DH6ZWOEM6G2H7LKZT37LYQVGGFAVCNFSM5R4QSO3KU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJRGMZDSOBVGMZQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
mreiche commented 9 months ago

It's a workaround.

Zocker1999NET commented 8 months ago

I have the same issue on:

Weirdly, I only have this issue on the user account I specifically created for podman. On my user account on the same system, the same compose file just works. I nuked ~/.config/cni & .local/share/containers on both accounts at the start and checked before each test that the previous containers & networks were no longer listed by podman. I also tried putting the podman account into the same groups as mine, without success. AFAIK those accounts have only a few differences where I could remotely imagine that those may could cause this issue.

Table of Differences Account Name | `zocker` | `podman` --- | --- | --- Home | `/home/zocker` | `/var/lib/podman-env` UID | 1000 | 995 Primary GID | 1000 | 994 `/etc/subuid` & `/etc/subgid` entries | `zocker:100000:65536` | `podman:165536:65536`

I tested that with this simple compose file:

version: "2"

services:
  test:
    image: hello-world