podman-compose
podman-compose copied to clipboard
RFE: Support network aliases
A docker-compose.yml file may define one or more aliases for a container, such that other containers in the same compose can use those aliases rather than the container name to resolve its ip address. E.g. from the documentation:
services:
some-service:
networks:
some-network:
aliases:
- alias1
- alias3
other-network:
aliases:
- alias2
Support this in podman-compose would permit a wider range of docker-compose setups to be used without modification.
This would require containers/libpod#4530 to be implemented first.
Does this problem still exist? I am not able to start a container using aliases with podman-compose at the moment... I always receive a KeyError on startup:
File ".../python3.9/site-packages/podman_compose.py", line 558, in assert_cnt_nets
net_desc = nets[net] or {}
KeyError: "system={'aliases': ['db']}"
Using the following compose.yaml:
version: "3.9"
services:
mariadb:
image: mariadb:10.6
networks:
system:
aliases:
- db
web:
aliases:
- db
networks:
default:
name: "system"
web:
quote from podman manpage
--network-alias=alias
Add network-scoped alias for the container. NOTE: A container will only have access to aliases on the first network that it joins. This is a limitation that will be removed in a later release.
so regarding
version: "3.9"
services:
mariadb:
image: mariadb:10.6
networks:
system:
aliases:
- sysdb
web:
aliases:
- webdb
networks:
default:
name: "system"
web:
@rhatdan do you suggest a specific sequence of podman commands to acchive that
$ podman network myproj-system
$ podman network myproj-web
$ podman run -ti --rm --network myproj-system --network-alias sysdb --network myproj-web --network-alias webdb busybox /bin/sh
@Schlumpf9 I've just pushed a fix that handles dicts and fixes KeyError
your case would work because in both it's called db
I cannot even use network alias at all. if i use the compose file above, i will get
File ".../python3.8/site-packages/podman_compose.py", line 1128, in _parse_compose_file
raise RuntimeError(f"missing networks: {missing_nets_str}")
@crazytaxi824 you are not using latest code, please upgrade to latest code using
pip3 install --user https://github.com/containers/podman-compose/archive/devel.tar.gz
@muayyad-alsadi thanks a lot.
@crazytaxi824 you are not using latest code, please upgrade to latest code using
pip3 install --user https://github.com/containers/podman-compose/archive/devel.tar.gz
This seems to fix the problem. It would be great if this could be released some time in the future so distributions could add this fix to their repositories. It seems the last release happened last december :)
Yep would if good if this could be released. Had to use the devel one to get it to work.
Hi,
Got the same issue on my side
Do you have any plan about a next release ? (the last one is from 2021-12-21, 4 days before the fix)
And: no, I don't want to pip install devel 🙂
Regards
I was very busy lately but the reason I did not release the branch there is a breaking change regarding putting all containers in a single pod or not. putting all containers in a single pod is a desirable feature but to release it I need to do the following
undo that or make it default to "in_1pod=false" then make a minor release then redo it then make another release with major version bump