containers / podman-compose

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

links: with dns name don't seem to work #912

Open oseiberts11 opened 2 months ago

oseiberts11 commented 2 months ago

Describe the bug

I have a docker-compose file with something like this fragment in it:

  machinedb:
    depends_on:
      - foo
      - bar
      - baz
      - quux
    links:
      # Avoid conflicts with hosts on the local/public network.
      - foo:foo.example
      - bar:bar.example
      - baz:baz.example
      - quux:quux.example

were the idea is that the address of the "foo" service is available under the dns name "foo.example".

This seems not to work. The services can't find "foo.example", but just plain "foo" is resolvable.

To Reproduce docker-compose.yml:

version: "3"
services:
  foo:
    image: ubuntu:focal
    entrypoint: [ 'sleep', '600' ]

  bar:
    image: ubuntu:focal
    entrypoint: [ 'sleep', '600' ]

  baz:
    image: ubuntu:focal
    entrypoint: [ 'sleep', '600' ]
    depends_on:
      - foo
      - bar
    links:
      - foo:foo.exmpl
      - bar:bar.exmpl
podman-compose up
# in other terminal
podman exec -ti try_baz_1 /bin/bash
# install anthing that would trigger dns resolution
apt install telnet
telnet foo
Trying 10.89.1.4...
telnet: Unable to connect to remote host: Connection refused
telnet foo.exmpl
telnet: could not resolve foo.exmpl/telnet: Name or service not known

Expected behavior The dns names foo.exmpl nd bar.exmpl should be known

Actual behavior They are not.

Output

$ podman-compose --version
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 5.0.1
podman-compose version 1.0.6
podman --version
podman version 5.0.1
exit code: 0
# This is on macos, using homebrew
$ podman-compose up
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 5.0.1
** excluding:  set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=try', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'try_default']
podman create --name=try_foo_1 --label io.podman.compose.config-hash=3b339efdaf7468e7ff24f0f68132d57897a50811b17283cae3fbc8f0521ac959 --label io.podman.compose.project=try --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@try.service --label com.docker.compose.project=try --label com.docker.compose.project.working_dir=/Users/oseibert/git/machinedb/machinedb/try --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=foo --net try_default --network-alias foo --entrypoint ["sleep", "600"] ubuntu:focal
7be1996d558d98f297143806c8f45b5836ab3424d7710ecb870c6a1a2965ae0f
exit code: 0
['podman', 'network', 'exists', 'try_default']
podman create --name=try_bar_1 --label io.podman.compose.config-hash=3b339efdaf7468e7ff24f0f68132d57897a50811b17283cae3fbc8f0521ac959 --label io.podman.compose.project=try --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@try.service --label com.docker.compose.project=try --label com.docker.compose.project.working_dir=/Users/oseibert/git/machinedb/machinedb/try --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=bar --net try_default --network-alias bar --entrypoint ["sleep", "600"] ubuntu:focal
83bb959b76abe155f88db739f34078e3a8c31065bac8d86b102b0fce53e05a53
exit code: 0
['podman', 'network', 'exists', 'try_default']
podman create --name=try_baz_1 --requires=try_bar_1,try_foo_1 --label io.podman.compose.config-hash=3b339efdaf7468e7ff24f0f68132d57897a50811b17283cae3fbc8f0521ac959 --label io.podman.compose.project=try --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@try.service --label com.docker.compose.project=try --label com.docker.compose.project.working_dir=/Users/oseibert/git/machinedb/machinedb/try --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=baz --net try_default --network-alias baz --entrypoint ["sleep", "600"] ubuntu:focal
50cb785ae7b6b33d6a241b918d34616d4f426204e2c0d12f0c1fbbc0a13533fd
exit code: 0
podman start -a try_foo_1
podman start -a try_bar_1
podman start -a try_baz_1

Environment:

Additional context

I read that links: is supposed to be deprecated and that you should do something with network: instead. However a quick reading of documentation that I found doesn't say how to select the dns names in the way that is done here.