Prometheus container exits because its config file is missing
/etc/prometheus/prometheus.yaml: no such file or directoryShort answer
Prometheus reads one config file, set with --config.file. The container exits when nothing exists at that exact path. In Docker Compose the usual reasons are a mismatch between the file name and the mount target, a command override that dropped the flag, or a host path that Docker turned into an empty directory.
Fix it fast
1Find out which cause you have
Print the resolved Compose file. It shows the real host path of each mount and any command that replaces the image default.
docker compose config docker compose logs --tail 20 prometheus2Match what you see, then jump to its fix
- 1
The error names a file such as prometheus.yaml, but the file you mounted is called prometheus.yml (or the other way round)The mount target and the config file name do not matchFix - 2
The service has a command: list in Compose, and the log complains about the config file or about a path you never setA command: entry replaced the image defaultsFix - 3
The mount source on the host is a directory although you meant a fileThe host file did not exist, so Docker created a directoryFix - 4
Your volume line mounts a folder onto /etc/prometheusA whole directory was mounted over /etc/prometheus and it lacks the fileFix
- 1
What does the error look like?
/etc/prometheus/prometheus.yaml: no such file or directory
Cause 1 of 4
The mount target and the config file name do not match
1Check
Prometheus loads the file named by --config.file. The official Docker example mounts the host file onto /etc/prometheus/prometheus.yml, so a differently named target leaves that path empty.
docker compose config | grep -n -A3 "volumes:"2Fix
Make the name in the volume line identical to the path Prometheus is told to load. The simplest way is to follow the documented example.
# compose.yaml
services:
prometheus:
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml3Verify
Recreate the container and confirm it stays up.
docker compose up -d --force-recreate prometheus
docker compose ps prometheusConfirmed by prometheus.io
Cause 2 of 4
A command: entry replaced the image defaults
1Check
In Compose, command overrides the image's default command. The Prometheus install page warns that extra parameters overwrite the defaults, so you must repeat the ones you still need.
docker compose config | grep -n -B1 -A4 "command:"2Fix
Put the config flag back next to the flags you added.
services:
prometheus:
image: prom/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
# your other flags go here, one per line3Verify
The service starts and stays in the running state.
docker compose up -d prometheus
docker compose ps prometheusConfirmed by docs.docker.com
Cause 3 of 4
The host file did not exist, so Docker created a directory
1Check
With the short volume syntax, a missing host path is created as a directory. Relative paths are resolved from the folder of the Compose file, not from where you ran the command.
ls -ld ./prometheus.yml2Fix
Stop the stack, remove the empty directory, create the real file in the Compose file's folder, then start again. Use the long volume syntax with create_host_path set to false if you want a missing path to fail loudly.
docker compose down
rmdir ./prometheus.yml
# create prometheus.yml next to compose.yaml, then:
docker compose up -d
# compose.yaml, long syntax
volumes:
- type: bind
source: ./prometheus.yml
target: /etc/prometheus/prometheus.yml
bind:
create_host_path: false3Verify
The path on the host is now a regular file, and the service runs.
ls -l ./prometheus.yml
docker compose ps prometheusConfirmed by docs.docker.com
Cause 4 of 4
A whole directory was mounted over /etc/prometheus and it lacks the file
1Check
A bind mount hides whatever the container directory held before. The documented directory form only works when the host folder itself contains prometheus.yml.
ls -l ./config2Fix
Add the config file to that host folder, or mount only the single file as in the first cause.
# host folder must contain prometheus.yml
volumes:
- ./config:/etc/prometheus3Verify
Restart the service and check it is running.
docker compose up -d --force-recreate prometheus
docker compose ps prometheusConfirmed by docs.docker.com
How do I stop it coming back?
- Keep one name for the config file (prometheus.yml) in the repository, in Compose and in any command: flag.
- Run docker compose config after every edit to see the real paths before starting the stack.
- Use the long volume syntax with create_host_path set to false for config files, so a typo fails at start instead of making a directory.
- When you add a command: entry, copy every flag the image default needs, not only the new one.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix