【问题标题】:Cannot mount file as a volume in nginx无法在 nginx 中将文件挂载为卷
【发布时间】:2020-07-10 06:32:42
【问题描述】:

我是 Docker 新手,我才刚刚开始学习。我在 Nginx 中挂载 index.html 时遇到了问题。 我正在使用适用于 Windows 10 Home 的 Docker 工具箱。我为我的虚拟机设置了共享文件夹1

当我想使用 index.html 安装服务器时,我看到了 404 Not Found 问题。 我使用以下命令来执行此操作。

docker 容器运行 --name con6 -p 80:80 -v /c/Docker/html://usr/share/nginx/html nginx

有人可以帮我吗?提前谢谢你

加载本地主机后我有以下输入:

2020/03/29 21:59:14 [error] 6#6: *1 "/usr/share/nginx/html/index.html/index.html" is not found (20: Not a directory) ,客户端:192.168.99.1,服务器:localhost,请求:“GET /index.html/ HTTP/1.1”,主机:“192.168.99.100”

192.168.99.1 - - [29/Mar/2020:21:59:14 +0000] "GET /index.html/ HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" "-"

【问题讨论】:

    标签: docker nginx docker-toolbox


    【解决方案1】:

    您能否运行以下命令将 HTML 挂载到容器中。

    docker container run --name con6 -p 80:80 --mount type=bind,source="/c/Docker/html",target="/usr/share/nginx/html" nginx
    
    

    供参考:-https://docs.docker.com/storage/bind-mounts/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-24
      • 2017-09-19
      • 2020-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多