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

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker Compose
Docker Compose

Are you learning Docker Compose ? Try our test we designed to help you progress faster.

Test yourself