0

Trying to do something simple, and just can't figure it out. I need some guidance towards a solution, please.

I have a docker compose file that creates a volume and maps to a directory elsewhere in the project. The desired outcome is having the contents of the "elsewhere" directory to be copied into the "created" volume.

Running the docker compose file creates the volume, but does not copy the files from the "elsewhere" directory.

Here is some code:

docker compose yml:

services:
   api:
      volumes:
         - ./data/media/audio:/test/media/audio

This creates a '/data/media/audio' on my machine and inside of the docker container (the 'created' volume), but does not copy the files from '/test/media/audio' (the 'elsewhere' volume) into '/data/media/audio'. All that is missing from this process is copying the '/test/media/audio' files into '/data/media/audio'.

I've spent the afternoon researching this problem and simply can't find a solution. At this point I'm not even sure what to look for. Any help is greatly appreciated.

Thanks!

mattBurnett
  • 94
  • 2
  • 9
  • 1
    A volume mount _always_ hides the content from the image and replaces it with the mounted host directory or volume. Nothing is copied _per se_ in either direction. This isn't specific to Docker, all Unix mounts work this way. You can't use a bind mount on its own to copy data out of an image, and the linked question says more on the topic. – David Maze Nov 21 '22 at 14:57

0 Answers0