How to run a Prometheus docker container and access through localhost port

Let us quickly explore the minimum required steps to run a docker Prometheus container and access the Prometheus dashboard from localhost.

Command to run Prometheus without any customization

The basic command to run Prometheus docker container is:

sudo docker run -p 9090:9090 prom/prometheus
  • sudo – if you are using a non-root user
  • the docker run command
  • -p followed by your local port 9090, and the container default port is 9090, so 9090:9090
  • Then the image name prom/prometheus
  • Once the container is up, you can access the Prometheus dashboard from a web browser.
Prometheus docker runtime example with localhost port access
Docker run Prometheus example localhost 9090

How to access Prometheus dashboard from a localhost port

To access the Prometheus dashboard, use the port you have defined in the previous step. I have used 9090, so in my case, it would be:

https://localhost:9090

References: