Container name resolving and networking

I am a little lost on how to make container known and reachable to each other.
Let’s say I have:

  virtualisation.oci-containers.containers = {
    whoami1 = {
      image = "docker.io/traefik/whoami:v1.9.0";
      ports = [ "127.0.0.1:8001:80" ];
    };
    whoami2 = {
      image = "docker.io/traefik/whoami:v1.9.0";
      ports = [ "127.0.0.1:8002:80" ];
    };
  };

It seems they do share the same network - but there are no names to refer to them:

$ docker cp whoami1:/etc/hosts -
127.0.0.1	localhost
::1	localhost
127.0.0.2	nixos.utm nixos
::1	nixos.utm nixos
10.88.0.1	host.containers.internal host.docker.internal
10.88.0.17	bc5910703e33 whoami1
$ docker cp whoami2:/etc/hosts -
127.0.0.1 localhost
::1 localhost
127.0.0.2 nixos.utm nixos
::1 nixos.utm nixos
10.88.0.1 host.containers.internal host.docker.internal
10.88.0.18 6e53af4729a2 whoami2

I would have hoped for both hosts files to list all the IPs and container names.

This is when using podman.

  virtualisation = {
    containers.enable = true;
    oci-containers.backend = "podman";
    podman = {
      enable = true;
      dockerCompat = true;
      # defaultNetwork.settings.dns_enabled = true;
    };
  };

As stated in the wiki you need to uncomment this line:

      # defaultNetwork.settings.dns_enabled = true;

As you might have guessed from the comment being there - I also tried that :slight_smile:

You prolly need to setup some bridge or else
https://discourse.nixos.org/t/bridge-network-for-containers/40158
https://docs.docker.com/network/network-tutorial-standalone/