springboot deployed to the docker, the problem can not find the file upload

Problem Description

Use springboot file uploads, local test no problem. After the service is deployed to docker, the upload again tested procedures are not being given, but the location is not expected to file.

 

demand

1. I want to upload files to the server root directory / root / boottest / upload , the code set to:

file:
  UploadPath: /root/boottest/upload

2. Start the service, upload files, the service is not an error, but not in the / root / boottest / upload to find the files I want to upload in

3. Find the file, use 

Find / -name " micro channel screenshot _20191216152340.png "

Docker found files are stored in a container, as follows:

 

 

Root cause

When you start mirroring, not mounted to upload directory

Solution

When start mirroring, with a directory to mount. E.g:

docker run -d -p 8080:8080 -v /root/boottest/upload:/root/boottest/upload -t boot/boot

 

Solve the problem

 

Guess you like

Origin www.cnblogs.com/Edward-Wang/p/12056156.html