title: Prometheus in Docker container can't reach Spring Boot application
body: <p>I have a Spring Boot application that is running on 9000 port locally (not in container). The application has configured actuator with Prometheus micrometer and the whole stats is available by URL localhost:9000/actuator/prometheus.</p>
  
  <p>I run Prometheus in Docker container using the following command:</p>
  
  <pre><code>docker run --name spring_boot_prometheus -p 9090:9090 -p 9000:9000 -v /Users/xyz/docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
  </code></pre>
  
  <p><strong>prometheus.yml</strong></p>
  
  <pre><code>global:
    scrape_interval:     5s
    evaluation_interval: 5s
  scrape_configs:
  - job_name: 'users-app'
    metrics_path: '/actuator/prometheus'
    static_configs:
    - targets: ['localhost:9000']
  </code></pre>
  
  <p>The command <code>docker ps</code> returns the following:</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                            NAMES
  1568ec9e8353        prom/prometheus     "/bin/prometheus --c…"   10 seconds ago      Up 9 seconds        0.0.0.0:9000-&gt;9000/tcp, 0.0.0.0:9090-&gt;9090/tcp   spring_boot_prometheus
  </code></pre>
  
  <p>The UI says that prometheus can't connect to spring boot endpoint but it's available. If I click on endpoint it redirects me to <code>1568ec9e8353:9000</code> instead of <code>localhost:9000</code>
  <a href="https://i.stack.imgur.com/sYcwd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sYcwd.png" alt="enter image description here"></a></p>
  
  <p>How can I fix the problem?</p>
  
  <p>Appreciate for your help!</p>