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
Using Docker Compose, how do you define that one service is dependent on another service?
Docker Compose SeniorHow 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 Junior