How do you mount a volume to your Docker Compose service?
Experience Level: Junior
Tags: Docker Compose
Answer
Add a property volumes: under your service. This way you can map a local folder to a specified folder in your service container.
version: "3.4"
services:
my-service:
volumes:
- ./webapp:/opt/webapp
Related Docker Compose job interview questions
How do you use definitions that are stored in multiple Docker Compose files?
Docker Compose JuniorHow do you mount a volume to your Docker Compose service?
Docker Compose JuniorWhy would you use Docker Compose instead of Docker?
Docker Compose JuniorWhat format does Docker Compose file support?
Docker Compose JuniorHow can you run multiple copies of Docker Compose file on the same host side by side?
Docker Compose Junior