Access localhost from container in addition to other network?

Hi everyone,

I do have caddy server running as reverse proxy as docker container with an external network:

services:
  caddy:
    image: caddy
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./data:/data
      - ./config:/config
      - ./Caddyfile:/etc/caddy/Caddyfile:ro

networks:
  default:
    external: true
    name: proxy-network

Now I want to use that container as a reverse proxy for other services running on the docker-host but not as docker container.
Is it possible to add another network (host-network) so I can acess these services via the container proxy?

Assuming you are running docker-ce on Linux, you can use the ip 172.17.0.1 (the default ip of the docker0 interface). Though, this only works if the application on the host either binds the port to 0.0.0.0, or to 172.17.0.1.

On Docker Desktop you could use host.docker.internal instead (see: docs) .

Thank you very much! I can access my host with the IP 172.17.0.1 :slight_smile: