如何将HTML文件上传到在Docker上运行的Apache Web服务器

发布于 2025-02-13 16:41:50 字数 344 浏览 0 评论 0原文

我从Apache Web服务开始。我正在使用HTTPD图像在Docker上运行它,并且在容器上绘制了主机端口81至80。

我已经创建了一个新的index.html,我想测试它作为我的新主页,但对于如何将其上传到服务器而言是一定的。

我不知道有任何GUI类型的方法,但无论如何都希望采用程序化方法。

我尝试使用卷曲命令(一些变体的反复试验)。一个例子是:

curl -u root -XPUT -H "content-type: application/html" @index.html http://localhost:81/index.html

有时返回现有索引。

I am starting out with Apache webservices. I am running it on Docker with the httpd image, and I have mapped host machine port 81 to 80 on the container.

I have created a new index.html which I want to test as my new home page, but at a loss as to how to upload it to the server.

I'm not aware of any GUI type methods, but in any case would prefer a programmatic approach.

I have tried using curl commands (trial and error of a few variations). One example is:

curl -u root -XPUT -H "content-type: application/html" @index.html http://localhost:81/index.html

Sometimes the existing index.html is returned, other times I get Error 405: Method Not Allowed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么这么可爱啊 2025-02-20 16:41:50

使用Docker CP
Docker cp ./index.html容器:/var/www/html/index.html
适应您的需求;要获取容器名称,请运行Docker PS。如果您的容器命名为Apache2,则完整命令将为:
Docker cp ./index.html apache2:/var/www/html/index.html

Use docker cp
docker cp ./index.html container:/var/www/html/index.html
Adapt paths to your needs; to obtain container name, run docker ps . If your container is named apache2, then full command will be:
docker cp ./index.html apache2:/var/www/html/index.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文