First of all here is my scenario
$ tree -a
├── 1.yml
├── 2.yml
└── .env
$ cat .env
COMPOSE_FILE=1.yml:2.yml
$ cat 1.yml
services:
myservice1:
image: bash
depends_on:
- myservice2
$ cat 2.yml
services:
myservice2:
image: bash
volumes:
- ./dir:/dir
Let’s do some tests
$ docker compose run --rm myservice1 ls -ld /dir
ls: /dir: No such file or directory
mmmhhh…
$ docker compose run --rm myservice2 ls -ld /dir
drwxr-xr-x 2 root root 4096 Jul 23 07:09 /dir
Ok, but … practically myservice1 cannot access to the directory /dir of myservice2 (it can only be done from the inside of myservice2).
What can be done?
What can be done to share a directory, or more generally, a volume among several services?
Practically the directive (specified in the 1.yml file)
depends_on:
- myservice2
it didn’t help …