【问题标题】:How to copy HTML onto index.html in docker如何将 HTML 复制到 docker 中的 index.html
【发布时间】:2022-11-25 11:04:00
【问题描述】:

这是我的 docker 文件 我想知道如何复制与我的 dockerfile 位于同一目录中的本地 html 代码。当我在我的 docker IP 上运行 curl 时,这个命令不知何故不起作用 这不是我的 html 代码,它是默认代码。

FROM httpd
EXPOSE 80
COPY public-html.html /usr/local/apache2/htdocs/

【问题讨论】:

    标签: docker dockerfile


    【解决方案1】:

    问题是您构建了映像,但没有运行它。

    通过将文件作为卷安装到容器中来运行它的示例:

    docker run -it --rm -d -p 8080:80 --name web -v ./public-html.html:/usr/share/nginx/html nginx
    

    现在你可以做一个curl http://localhost:8080

    构建它的例子:

    FROM nginx:latest
    COPY ./public-html.html /usr/share/nginx/html/index.html
    

    更多资讯here

    【讨论】:

      猜你喜欢
      • 2015-11-16
      • 2014-10-14
      • 2021-03-28
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      • 2021-04-23
      • 2019-08-30
      相关资源
      最近更新 更多