【问题标题】:How to write a Dockerfile in Windows? Where the images are stored in Windows?如何在 Windows 中编写 Dockerfile?图像存储在 Windows 中的什么位置?
【发布时间】:2022-01-05 14:36:25
【问题描述】:

我不了解 Windows 上的 docker 的一些事情。

我需要编写一个简单的 Dockerfile。我需要在 VS Code 中执行此操作以将其推送到我的 GitLab 存储库。这是我的问题:我需要使用 nginx 图像,但需要使用我自己的 .html 部分。 我知道我应该用 COPY 指令来做——比如 COPY index.html path 和......什么路径? nginx 在 Windows 中的位置在哪里?在 linux 中类似于 /usr/share/... 但我在 WSL 中找不到类似的东西... 我正在使用 Docker Desktop 和 WSL。

请帮我解决这个问题...

【问题讨论】:

  • 除非您点击“切换到 Windows 容器”,否则您的 Nginx 容器 Linux。目标路径在容器内。
  • “目标路径在容器内”是什么意思?我需要图片路径
  • 根据docsCOPY 命令用于将文件或目录从主机复制到容器。您说目标路径有问题,因为您只知道如何在 Linux 中执行此操作。但它是Linux。抱歉,我真的不知道你想如何在此处包含 Windows 路径。

标签: docker nginx dockerfile windows-subsystem-for-linux nginx-location


【解决方案1】:
FROM nginx:alpine
COPY default.conf /etc/nginx/conf.d/default.conf
COPY ./MyWebFolder /usr/share/nginx/html

这是一个简单的 docker 文件,我用来将“MyWebFolder”中的 html 文件复制到将托管网站的 nginx html 文件夹中。您不必担心内置于 windows docker 或 linux 的图像。只要确保镜像是由 docker desktop 构建在 linux 容器中的。 (https://docs.docker.com/engine/faq/)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-29
    • 1970-01-01
    相关资源
    最近更新 更多