how to run prometheus on docker

66 views
Skip to first unread message

babis kagelidis

unread,
Sep 6, 2020, 2:18:42 PM9/6/20
to Prometheus Users
Hello , i try to run prometheus on docker with this command :

sudo docker run -d --name prometheus-server -p 9090:9090 \
-v /home/mccdev/prometheus/prometheus/prometheus.yml:/prometheus.yml \
prom/prometheus \
--config.file=/prometheus.yml


but container is always exited immediatelly and i have no access to localhost:9090.

What can i do to set container to 'up'?

Praveen Srinivasan

unread,
Sep 7, 2020, 11:55:15 PM9/7/20
to Prometheus Users
Please check the container logs, there might be some permission issues or something else. But logs will give you the detail.

kiran

unread,
Sep 8, 2020, 12:31:52 AM9/8/20
to babis kagelidis, Prometheus Users
 I had the same issue where containers are exiting the moment they are created. It was because of permission issue to the directory where Prometheus is writing data to.
--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/dbe8d871-d3c4-43ae-b6bc-d90104f5d84cn%40googlegroups.com.

babis kagelidis

unread,
Sep 8, 2020, 1:23:12 PM9/8/20
to Prometheus Users
my container log is
"level=error ts=2020-09-08T17:06:51.460Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:06:56.878Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:06:59.519Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:07:05.024Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:07:12.431Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:07:18.013Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:07:40.173Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:07:55.992Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:08:19.886Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:08:48.089Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
level=error ts=2020-09-08T17:09:40.235Z caller=main.go:283 msg="Error loading config (--config.file=/prometheus.yml)" err="read /prometheus.yml: is a directory"
"
what is going wrong?

Στις Τρίτη, 8 Σεπτεμβρίου 2020 στις 7:31:52 π.μ. UTC+3, ο χρήστης kira...@gmail.com έγραψε:
 I had the same issue where containers are exiting the moment they are created. It was because of permission issue to the directory where Prometheus is writing data to.

On Sunday, September 6, 2020, babis kagelidis <babiska...@gmail.com> wrote:
Hello , i try to run prometheus on docker with this command :

sudo docker run -d --name prometheus-server -p 9090:9090 \
-v /home/mccdev/prometheus/prometheus/prometheus.yml:/prometheus.yml \
prom/prometheus \
--config.file=/prometheus.yml


but container is always exited immediatelly and i have no access to localhost:9090.

What can i do to set container to 'up'?

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.

Brian Candler

unread,
Sep 9, 2020, 3:02:06 AM9/9/20
to Prometheus Users
I don't think the error message could be any clearer.  You told it to read the file /prometheus.yml, but /prometheus.yml is a directory, not a file.

The most likely reason is here:

Namely, the file didn't exist on the host at the time you mounted it with -v, so it got created as a directory instead.

Note that volume-mounting a single file like this is unwise anyway, in the case that you might want to change this file while the container is running:
It's better to mount the enclosing directory.
Reply all
Reply to author
Forward
0 new messages