Apache page retains after exiting docker container

2019-09-07 04:15发布

问题:

I'm new to docker. I tried executing the following docker command to created a container,

docker run -d -p 9999:80 httpd

After this, when i visited the URL http://127.0.0.1:9999/, It loads with "It works!" message. So, to change the message, I went inside the httpd container and changed the value of /usr/local/apache2/htdocs/index.html (Hope, that is the correct location) to <html><body><h1>It works at port 9999!</h1></body></html>.

But still it is showing the same old message and the weird part is it is still showing up after removing the container. Am i doing anything wrong or is this coming from any cache or something?

Please help.

Edit: I found it is due to browser cache and nothing else.

回答1:

You did a modification to a running container, but if you want to see it, you have to

docker commit -t my_apache_modified

your container, and then launch your new image, with a

docker run -d -p 9999:80 my_apache_modified

see the doc

https://docs.docker.com/reference/commandline/commit/

Keep in mind that the preferred way is to modify your Dockerfile, and build a new image



回答2:

I can't reproduce your error here.

Try that:

docker run -d --name httpdtest -p 9999:80 httpd

docker exec -it httpdtest bash

echo "test" >> htdocs/index.html

And try to see in your browser. (http://127.0.0.1:9999)



标签: apache docker