Search code examples
podman

Accessing host from inside container


What I am trying to accomplish is to connect to a database installed on the host system. Now there is a similar question already for docker, but I could not get that to work with Podman, I imagine because networking works a bit differently here.

My solution so far has been to use --add-host=dbhost:$(ip route show dev cni-podman0 | cut -d\ -f7), but I am not certain that's a good idea and it's not going to work when a different network is used.

What is the best approach to accomplish this? Is there perhaps a default hostname for the container host already defined?


Solution

  • You can also use host.containers.internal in podman. It's basically Podman's equivalent to host.docker.internal, but works out of the box.