从容器更改Web服务器(apache)网页不会生效

时间:2018-04-11 12:25:24

标签: apache docker

我使用httpd image:

创建了一个docker容器
sudo docker run -dt -p 8080:80 httpd  

我通过输入http://localhost:8080

验证了它的工作原理

我在容器内打开了shell:

docker exec -it <container_id> bash 

我更改了位于以下位置的默认网页内容(index.html

/usr/local/apache2/htdocs/index.html

我想看到新的变化但是当我刷新页面时没有任何事情发生 我重新启动了容器,它仍显示默认网页 我试图在容器的shell中重新启动httpd服务,但没有成功,这就是我尝试过的(基于this):

# sudo service apache2 restart
  apache2: unrecognized service
# service httpd restart
  httpd: unrecognized service
# systemctl start apache2.service
  Failed to get D-Bus connection: Unknown error -1
# /etc/init.d/apache2 reload
  bash: /etc/init.d/apache2: No such file or directory

1 个答案:

答案 0 :(得分:0)

这是FireFox的缓存问题 我在私密浏览时打开它,它工作正常。

验证它的一个好方法是运行:

curl http://localhost:8080 

我将返回更新的GET请求。