Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot Spring引导停靠应用程序在主机中创建文件_Spring Boot_Docker_Docker Machine - Fatal编程技术网

Spring boot Spring引导停靠应用程序在主机中创建文件

Spring boot Spring引导停靠应用程序在主机中创建文件,spring-boot,docker,docker-machine,Spring Boot,Docker,Docker Machine,我有spring boot应用程序,在docker内部运行。 现在,我正在SpringBoot中使用 File file = new File("/var/www/html"); File f = new File(file, System.currentTimeMillis() + ".jpg"); 我想公开访问这个文件,所以必须在var/www/html文件夹中创建 但这样做,我无法看到var/www/html中的任何文件,因为应用程序正在docker容器中运行。 如何更改Docker容器

我有spring boot应用程序,在docker内部运行。 现在,我正在SpringBoot中使用

File file = new File("/var/www/html");
File f = new File(file, System.currentTimeMillis() + ".jpg");
我想公开访问这个文件,所以必须在var/www/html文件夹中创建

但这样做,我无法看到var/www/html中的任何文件,因为应用程序正在docker容器中运行。
如何更改Docker容器卷,以便在主机中创建上述位置的文件?

运行Docker映像时,您需要装入卷

如果通过执行docker run命令来运行docker映像,请在命令中添加以下内容:


码头工人跑
-v/var/www/html:/var/www/html
..

这是正确的命令吗?因为对于volumtag:docker run-v:where是错误的?我补充说。。。意味着你的另一个论点不起作用。。不应该使用容器路径?在命令中都是相同的/var/www/html..docker run--restart always--name test-v/var/www/html:/var/www/html-d-p 82:82 test您在这个位置向docker用户授予权限了吗?