Home > Software engineering >  How to upload HTML files to Apache Webserver running on Docker
How to upload HTML files to Apache Webserver running on Docker

Time:07-08

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.

CodePudding user response:

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

  • Related