I'm using docker-compose
to spawn two containers. I would like to share the /tmp
directory between these two containers (but not with the host /tmp
if possible). This is because I'm uploading some files through flask
to /tmp
and want to process these files from celery
.
flask:
build: .
command: "gulp"
ports:
- '3000:3000'
- '5000:5000'
links:
- celery
- redis
volumes:
- .:/usr/src/app:rw
celery:
build: .
command: "celery -A web.tasks worker --autoreload --loglevel=info"
environment:
- C_FORCE_ROOT="true"
links:
- redis
- neo4j
volumes:
- .:/usr/src/app:ro
You can used a named volume:
flask:
build: .
command: "gulp"
ports:
- '3000:3000'
- '5000:5000'
links:
- celery
- redis
volumes:
- .:/usr/src/app:rw
- tmp:/tmp
celery:
build: .
command: "celery -A web.tasks worker --autoreload --loglevel=info"
environment:
- C_FORCE_ROOT="true"
links:
- redis
- neo4j
volumes:
- .:/usr/src/app:ro
- tmp:/tmp
When compose creates the volume for the first container, it will be initialized with the contents of /tmp from the image. And after that, it will be persistent until deleted with docker-compose down -v
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With