The docker-compose.yml file I am using is following:
services:
web:
image: nginx:stable-alpine
ports:
- "8080-8130:80"
volumes:
- ${TEMPDIR}:/run
I launch 20 containers with the following command:
TEMPDIR=`mktemp -d` docker-compose up -d --scale web=20
All of the containers launch ok, but they all have the same temp volume mounted at /run, whereas I need each running container to have a unique temp volume. I understand that the problem is that the above yml file is doing Variable Substitution whereas what I need is Command Substitution but I could not find any way of doing that in the official reference , especially when launching multiple instances of the same docker image. Is there some way to fix this problem?
Maybe what you are looking for is tmpfs
.
Mount a temporary file system inside the container. Can be a single value or a list.
You can use it simply like this
services:
web:
image: nginx:stable-alpine
ports:
- "8080-8130:80"
tmpfs: /run
Here are the references:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.