Traefik connects to a service binding to localhost

I have traefik running inside a docker container in bridge networking mode (by default).
On the same host, I have home assistant running in another container in host networking mode (hass needs this for service discovery).

Now I want to connect traefik to hass so that they can share the same port (80, 443/tcp). Is it possible?

The host has a static IP but I can't ping its IP from inside traefik container. I can ping other IP on the same network.

The short answer is you can not. Containers are used for isolation, so this behavior is intended.

The long answer is, there seem to be some workarounds, but no guarantees.

Thanks for your reply. The workaround doesn't do it for me. From inside docker, I can't connect to the services binding to host through the docker gateway IP.

If I bind traefik to host network then I can connect it to home assistant, but I will have to do expose other containers on host also in order for traefik to connect to them. I'd rather avoid doing this.

I could bypass traefik and connect to hass directly, is there any way I can do this so that I don't have to put hass on different/non-standard ports?