I have a server that I've connected to using autossh. When I run curl http://localhost:9100/metrics on the host system, I am able to retrieve metrics from the server. I am trying to forward port 9100 to the Prometheus Docker container in my docker-compose.yml file.
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- "9090:9090"
expose:
- "9100" # Node Exporter
volumes:
- $DOCKERDIR/appdata/prometheus/config:/etc/prometheus
- $DOCKERDIR/appdata/prometheus/data:/prometheus
restart: unless-stopped
command:
- "--config.file=/etc/prometheus/prometheus.yml"
extra_hosts:
- "host.docker.internal:host-gateway"
When I connect to the Prometheus container and run wget http://host.docker.internal:9100, I receive the following error message:
/prometheus $ wget http://host.docker.internal:9100
Connecting to host.docker.internal:9100 (172.17.0.1:9100)
wget: can't connect to remote host (172.17.0.1): Connection refused
Why do i not have access to the port inside the container?