Docker Community Forums

Share and learn in the Docker community.

Docker compose volume configuration

Hello,

I tried to use docker compose to reproduce an aws ecs task behavior.

I ve got a first docker file defined as follows :

Blockquote
cat Dockerfile FROM xxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/clouddevops/prometheus:v2.7.2 USER root COPY ./prometheus.yml /etc/prometheus/prometheus.yml VOLUME ["prometheus-config"] sudo docker build .
Sending build context to Docker daemon 3.584kB
Step 1/4 : FROM xxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/clouddevops/prometheus:v2.7.2
—> 2a68492b2466
Step 2/4 : USER root
—> Using cache
—> 1b8b5b759360
Step 3/4 : COPY ./prometheus.yml /etc/prometheus/prometheus.yml
—> Using cache
—> 013ba2736435
Step 4/4 : VOLUME [“prometheus-config”]
—> Using cache
—> b5c9584346f3
Successfully built b5c9584346f3
$ sudo docker run b5c9584346f3
level=info ts=2019-06-11T09:16:23.683243979Z caller=main.go:302 msg=“Starting Prometheus” version="(version=2.7.2, branch=HEAD, revision=82f98c825a1437c0a24056eb4dc986d9a3fc7fae)"
level=info ts=2019-06-11T09:16:23.683715464Z caller=main.go:303 build_context="(go=go1.11.5, user=root@ab86c672c33a, date=20190302-14:57:04)"
level=info ts=2019-06-11T09:16:23.68396345Z caller=main.go:304 host_details="(Linux 4.14.77-86.82.amzn2.x86_64 #1 SMP Mon Dec 3 19:40:13 UTC 2018 x86_64 cf0dc8dbdaf4 (none))"
level=info ts=2019-06-11T09:16:23.684214339Z caller=main.go:305 fd_limits="(soft=1024, hard=4096)"
level=info ts=2019-06-11T09:16:23.684451168Z caller=main.go:306 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2019-06-11T09:16:23.685387391Z caller=main.go:620 msg=“Starting TSDB …”
level=info ts=2019-06-11T09:16:23.699572665Z caller=main.go:635 msg=“TSDB started”
level=info ts=2019-06-11T09:16:23.700399665Z caller=main.go:695 msg=“Loading configuration file” filename=/etc/prometheus/prometheus.yml
level=info ts=2019-06-11T09:16:23.704783889Z caller=main.go:722 msg=“Completed loading of configuration file” filename=/etc/prometheus/prometheus.yml
level=info ts=2019-06-11T09:16:23.705018882Z caller=main.go:589 msg=“Server is ready to receive web requests.”
level=info ts=2019-06-11T09:16:23.70526578Z caller=web.go:416 component=web msg=“Start listening for connections” address=0.0.0.0:9090

And an other docker file :

Blockquote
sudo docker build . Sending build context to Docker daemon 9.216kB Step 1/8 : FROM xxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/clouddevops/python3:3.7.2 ---> 4399ebb4ff24 Step 2/8 : COPY ./ecs_service_discovery.py /etc ---> Using cache ---> 826aff5ec789 Step 3/8 : WORKDIR /etc ---> Using cache ---> 47476e8808f9 Step 4/8 : VOLUME ["prometheus-config"] ---> Using cache ---> a102ca90b46a Step 5/8 : ENTRYPOINT ["python3","ecs_service_discovery.py","--cluster","ecs-dev-toto-fargate","--path","/prometheus-config"] ---> Using cache ---> 40a61d2ac921 Successfully built 40a61d2ac921 sudo docker run 40a61d2ac921

Here is my docker compose file :

Blockquote
version: “3.7”
services:
prometheus:
image: prometheus:v1
volumes:
- “prometheus-config:/prometheus-config”
prometheus_ecs_discovery:
image: prometheus_ecs_discovery:v1
volumes:
- “prometheus-config:/prometheus-config”
volumes:
prometheus-config:

But when launching docker compose :

Blockquote
$ sudo docker-compose up -d
Recreating 6c520208b957_prometheus_prometheus_1 … error
Recreating 500c6b892c7a_prometheus_prometheus_ecs_discovery_1 …
ERROR: for 6c520208b957_prometheus_prometheus_1 Cannot create container for service prometheus: invalid volume specification: ‘9bfd75554697e10b5be23e3da7a881ac72a04e4e6cd154cbddddc28e97ff1d97:prometheus-config:rw’: invalid mount config for type “volume”: invalid mount path: 'pRecreating 500c6b892c7a_prometheus_prometheus_ecs_discovery_1 … error
ERROR: for 500c6b892c7a_prometheus_prometheus_ecs_discovery_1 Cannot create container for service prometheus_ecs_discovery: invalid volume specification: ‘e953ef7248fdd938e0f1c60ec9675dd6c65168db05e9f412ed0510922d2034e5:prometheus-config:rw’: invalid mount config for type “volume”: invalid mount path: ‘prometheus-config’ mount path must be absolute
ERROR: for prometheus Cannot create container for service prometheus: invalid volume specification: ‘9bfd75554697e10b5be23e3da7a881ac72a04e4e6cd154cbddddc28e97ff1d97:prometheus-config:rw’: invalid mount config for type “volume”: invalid mount path: ‘prometheus-config’ mount path must be absolute
ERROR: for prometheus_ecs_discovery Cannot create container for service prometheus_ecs_discovery: invalid volume specification: ‘e953ef7248fdd938e0f1c60ec9675dd6c65168db05e9f412ed0510922d2034e5:prometheus-config:rw’: invalid mount config for type “volume”: invalid mount path: ‘prometheus-config’ mount path must be absolute
ERROR: Encountered errors while bringing up the project.

Any ideas ?

Thanks in advance for your help.