Install Prometheus using Docker Compose

Prometheus is an open-source monitoring application. It will collect and store metrics of the running application over time. To install Prometheus using Docker Compose, please select the version you want to install on the Prometheus Docker Hub page https://hub.docker.com/r/prom/prometheus first. Then use the docker-compose.yml file with the following content to install it:

By default, Prometheus runs on port 9090, guys!

Please run the command “docker compose up” in the directory containing this docker-compose.yml file, you will see the following results:

Looking at the above log messages, you can see that, by default, Prometheus is using a configuration file located at “/etc/prometheus/prometheus.yml”. The contents of this file are as follows:

I will explain the content of the Prometheus configuration file in the following articles.

Now, to be able to edit the content of this configuration file conveniently, you can create a new file prometheus.yml with the above content, contained in a certain folder. Then edit the contents of the above docker-compose.yaml file to mount this newly created prometheus.yml file pointing to the path “/etc/prometheus/prometheus.yml” inside the container. My example is as follows:

Now, rerun “docker compose up” and go to the address http://localhost:9090, you will see the following results:

Add Comment