Running Prometheus on Docker

After having created the configuration file, we can use a volume mount to inject this configuration file into the Docker containers we are about to start.

For this example, we will assume that you have the MyEvents application running in Docker containers on your local machine and that the containers are attached to a container network named myevents (whether you created the containers manually or via Docker Compose does not really matter).

For this reason, starting both applications is easy enough. We'll start by defining a separate container network for the monitoring components:

$ docker network create monitoring 

Next, create a new volume in which the Prometheus server can store its data:

$ docker volume create ...

Get Cloud Native programming with Golang now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.