Understanding docker-compose.yml Volumes

Asked 2 years ago, Updated 2 years ago, 110 views

  • Mounting Host Side Folder A to Container Folder B
  • Save folder C directly under folder B in container to named volume

If you set the above in docker-compose.yml, folder C appears directly under folder A on the host side, but folder C is empty (there is a file in folder C on the container side).
Why is host side folder C empty?

services:
  app:
    images —php
    volumes:
      - Folder A: Folder B
      - volumeC —Folder C
volumes:
  volumeC:

docker docker-compose

2022-09-30 14:28

1 Answers

  • Folder A: The designation of folder B is called "bound mount" and links local folder A with container folder B.

On the other hand, self-created volumes do not bind mount, so they are used to perpetuate data in an area called Docker Volume.In this case, there is no link to the local file system, so the file is not stored in folder C, nor is there a link.


2022-09-30 14:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.