We can use –mount type=bind parameter to mount single file
docker run -d -p 9090:9090 --mount type=bind,source=/opt/prometheus/prometheus.yml,target=/etc/prometheus/prometheus.yml prom/prometheus:v2.22.0
Using docker-compose file
version: "3.7"
services:
prometheus:
image: prom/prometheus:v2.22.0
volumes:
- type: bind
source: /opt/prometheus/prometheus.yml
target: /etc/prometheus/prometheus.yml
ports:
- 9090:9090
More : https://stackoverflow.com/questions/42248198/how-to-mount-a-single-file-in-a-volume