Files not persisting with Docker-Compose and Volumes

I have an api running that needs images uploaded to it.

I’ve mounted the volume with the docker. When I upload a file and then retrieve it the file is found. If I close the container and re-build it the file is gone.

When I look at the /mnt/poductionvolume/data/ folder the /uploads folder is present but empty.

It seems that the files are not being copied to the mounted volume.

Any help is appreciated.

Docker-Compose File

File  api:
    container_name: api
    build: ../Indy-Distro-App/indy-distro-server
    restart: always
      - API_HOST=${API_HOST}
     - "8888:8888"
       - 8888
      - mongo-database
      - /mnt/productionvolume/data/uploads:/uploads

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Not a volumes expert but you may need to define top-level named volume since you want to reuse them.

Have a good read through the docs and the first example.