Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: Support network aliases #88

Open
larsks opened this issue Nov 18, 2019 · 10 comments
Open

RFE: Support network aliases #88

larsks opened this issue Nov 18, 2019 · 10 comments

Comments

@larsks
Copy link

larsks commented Nov 18, 2019

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/podman#4530 to be implemented first.

@Schlumpf9
Copy link

Schlumpf9 commented Dec 25, 2021

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:

@muayyad-alsadi
Copy link
Collaborator

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

muayyad-alsadi added a commit that referenced this issue Dec 25, 2021
@muayyad-alsadi
Copy link
Collaborator

@Schlumpf9 I've just pushed a fix that handles dicts and fixes KeyError

your case would work because in both it's called db

@crazytaxi824
Copy link

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}")

@muayyad-alsadi
Copy link
Collaborator

@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

@crazytaxi824
Copy link

@muayyad-alsadi thanks a lot.

@peacememories
Copy link

peacememories commented Jun 7, 2022

@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 :)

@pyrossh
Copy link

pyrossh commented Jun 15, 2022

Yep would if good if this could be released. Had to use the devel one to get it to work.

@gwallet
Copy link

gwallet commented Mar 22, 2023

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

@muayyad-alsadi
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants