It's easy to get a demo Prometheus up and running with Docker. How do you take it beyond that and provide your own configuration?

docker run -p 9090:9090 prom/prometheus is all is takes to get Prometheus running on http://localhost:9090/. For production use though you'll want to specify your own configuration, and it's always good to use source control.

Prometheus Console

Docker makes this easy with layers, allowing you to take an existing image and make changes on top of it. Let's start by creating a simple Prometheus configuration file:

cat <<EOF > prometheus.yml
global:
  scrape_interval:     10s
  evaluation_interval: 10s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

EOF

This tells the Prometheus server to scrape itself on port 9090.

Now let's create a Dockerfile that adds this on top of the prom/prometheus image:

cat <<EOF > Dockerfile
FROM prom/prometheus

# Add in the configuration file from the local directory.
ADD prometheus.yml /etc/prometheus/prometheus.yml
EOF

Next we can build and run it:

docker build -t prometheus_simple .
docker run -p 9090:9090 prometheus_simple

If you visit http://localhost:9090/consoles/prometheus.html you'll see the Prometheus console!

You can add more files for rules and consoles, and check it all into source control. For example, the configuration for this post can be found on Github.