Docker-compose volume storing image

In my Web API I receive images. These images should be stored, prefferable in my local directory. My project uses docker (compose). I managed to use a volume where the images are getting stored in a folder called unfiltered_images in the docker container. However, the saved images do not appear into my specified folder on my d-drive. docker-compose
services:
apitest.api:
image: ${DOCKER_REGISTRY-}apitestapi
build:
context: .
dockerfile: apitest.API/Dockerfile
volumes:
- "D:/image_test:/unfiltered_images"
services:
apitest.api:
image: ${DOCKER_REGISTRY-}apitestapi
build:
context: .
dockerfile: apitest.API/Dockerfile
volumes:
- "D:/image_test:/unfiltered_images"
In the future. I want to deploy this app onto my Raspberry Pi where an external hard disk will be used to store the images.
3 Replies
SteveTheMadLad
SteveTheMadLad•4d ago
Not sure I'll be able to follow up if you answer, but just to get the obvious things out of the way so that it may help others: - if you docker exec -it apitest.api ls /unfiltered_images can you see the actual files? - if you docker exec -it apitest.api touch /unfiltered_images/chicken.png, can you then see the file? EDIT to add: the indentation in the compose file seems to be a little off for the volume, yaml can get a little weird, I'm guessing it should give you an error but it's probably worth it to fix it and try again, unless it's just a copy-paste gone wrong. EDIT on top of the edit: if your app is running as user app, you could add -u app before -it in those docker exec commands, otherwise you're likely to execute them as root, I think.
electronic heartbreak.
electronic heartbreak.OP•4d ago
hi there. thanks for your reply. for the creation of my docker containers i fully rely on the build docker-compose function in Visual Studio. I deleted the unfiltered_images folder, ran the application again and posted a single image. in my docker-desktop i can see the the files in the map (see screenshot). This folder also becomes present in my project structure in Visual Studio.
No description
electronic heartbreak.
electronic heartbreak.OP•4d ago
The images do get added to the container directory. But what i want to achieve is that the images also get stored in my d-drive. I see now that the host folder does get created, but there are no files into the folder being written. oh my god I FANALLY HAVE IT 😭 . This is the volume:
volumes:
- D:/image_test:/unfiltered_images
volumes:
- D:/image_test:/unfiltered_images
This is the storage path in my code:
public string StoragePath => @"/unfiltered_images/";
public string StoragePath => @"/unfiltered_images/";
Want results from more Discord servers?
Add your server