2

I'm trying to save data from my docker app to a host folder. My dockerfile is:

FROM python:3 # set a directory for the app WORKDIR /usr/src/app # copy all the files to the container COPY . . # install dependencies RUN pip install --no-cache-dir -r requirements.txt EXPOSE 8050 CMD ["python", "./app.py"] 

I then build the image:

docker build <path> -t <tag> 

And then run:

docker run -p 8050:8050 <tag> 

In order to save the output from the docker app, which I was trying to do like this

pd.DataFrame(rows).to_excel('S:/Folder1/Folder2/Folder3/file.xlsx', index=False) 

I have to mount the volume, within Docker Settings>Resources>File Sharing I've added the directory 'S:/Folder1/Folder2/Folder3/' so that it can be mounted into Docker containers.

And then I tried to run the image:

docker run -p 8050:8050 -v "s:/folder1/folder2/folder3/":"/data" <tag> 

this pop ups a window "Docker wants to access to C\dc\Shared\folder1\folder2\folder3" And I can choose to share or cancel, after selecting share, folder 3 is created in the right location but I get the error:

docker: Error response from daemon: error while creating mount source path '/host_mnt/uC/dc/Shared/folder1/folder2/folder3/': mkdir /host_mnt/uC: operation not permitted. 

If I try a location on my C: drive this works without problems, it's just the shared drive that is giving me problems.

What is the right way to mount the volume so I can then save to that folder? Thank you

4
  • Do you call pd.DataFrame(rows).to_excel from inside docker? If so you do wrong. You have to call /data/file.xls instead. Commented Aug 14, 2020 at 10:25
  • I just tested with my windows. Shared directory in docker settings: C:\Development\temp Built image there with your commands. Started it's shell with docker run -it -p 8050:8050 -v "C:\Development\temp":"/data" test bash Then I was able to write new file echo "Testing" > /data/testing to mounted directory. So does your Python code. Commented Aug 14, 2020 at 10:36
  • @GintsGints yes I call it from inside docker - I'm not sure what you mean by call /data/file.xls instead though Commented Aug 14, 2020 at 10:53
  • You cannot use windows path inside docker container. Use linux path instead. Commented Aug 14, 2020 at 11:00

1 Answer 1

0

Your containerized app should call /data folder instead.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks! But I think the error occurs before saving, docker: Error response from daemon: error while creating mount source path '/host_mnt/uC/dc/Shared/folder1/folder2/folder3/': mkdir /host_mnt/uC: operation not permitted.
Try repeat my test.
what does this mean?
Can you execute your container bash, and create file when inside container?
Do you mean execute this? docker run -p 8050:8050 -v "s:/folder1/folder2/folder3/":"/data" <tag>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.