Skip to main content
In this lesson you’ll run Prometheus inside a Docker container. The workflow mirrors a non-containerized setup: pull the official prom/prometheus image, provide a prometheus.yml configuration file, bind-mount that file into the container, and expose Prometheus’ port (9090) on the host.
A simple flow diagram titled "Prometheus Docker" showing the prom/prometheus Docker image being pulled from DockerHub. It illustrates using a prometheus.yml configuration and then exposing ports and binding mounts for the container.
Overview:
  • Host stores prometheus.yml and a directory for TSDB data.
  • Docker runs prom/prometheus with the host config file bind-mounted into the container.
  • Port 9090 is mapped so the UI and API are reachable at http://localhost:9090.

1. Create the Prometheus configuration on the host

Create or edit prometheus.yml on your host. The configuration format is identical to bare-metal or VM installations. Example minimal config that scrapes Prometheus itself:
Save this file at a path you’ll use for the bind mount (for example /path/to/prometheus.yml).

2. Run Prometheus in Docker

Run the official Prometheus image and bind-mount the configuration file and a data directory. This example runs Prometheus detached, maps port 9090, mounts both the config file and a persistent data directory, and enables the lifecycle endpoint for HTTP-triggered reloads:

3. Docker run flags — quick reference

4. Lifecycle reload and useful commands

If you omit --web.enable-lifecycle, Prometheus will not respond to HTTP reload requests. Either restart the container after editing prometheus.yml (for example docker restart prometheus) or start Prometheus with --web.enable-lifecycle and trigger a reload by POSTing to http://localhost:9090/-/reload.
Useful commands:
  • Follow logs:
    • docker logs -f prometheus
  • Restart container:
    • docker restart prometheus
  • Trigger lifecycle reload (when --web.enable-lifecycle is enabled):

5. Verify Prometheus is running

  • Visit the UI at: http://localhost:9090
  • Check Status -> Targets to confirm configured scrape targets are UP.
  • Use logs (docker logs -f prometheus) for troubleshooting.

References and further reading

That’s it — the internal Prometheus configuration and behavior are identical to a non-containerized setup. Bind mounts keep the host config and data persistent and in sync with the container, while port mapping exposes the UI and API on the host.

Watch Video