docker 容器不会运行 apache2 虚拟主机

问题描述 投票:0回答:0

我正在学习 docker.. 我构建了 docker 镜像,在 ubuntu 基础上包含 apache2,然后我创建了我的 apache 虚拟主机目录并加载我的 index.html 和 [虚拟主机].conf,重新加载 apache 配置。

构建过程顺利完成,我可以在我的本地 docker 存储库中看到新图像。我可以从它创建一个容器,并通过 docker host ip:port 查看它在浏览器中运行。然后正如预期的那样,当我停止容器时,浏览器找不到该网站。

但是有两个问题:

  1. 浏览器只显示默认的 Apache 'It works!'网页;不是我的虚拟主机。

  2. 当我尝试查看 docker 容器日志以找出根本原因时,我看到我的 docker 以 root 身份安装(进入我的 lubuntu VM),因此(我认为)阻止我访问 docker 容器/日志文件夹。我不知道 root 密码,无论如何,了解 lubuntu VM 映像的 root 用户没有密码?

这是我的 Dockerfile:

FROM ubuntu
LABEL maintainer="[email protected]"
RUN apt-get update 
RUN apt-get install apache2 -y 
RUN mkdir /var/www/html/tutorialDocker
COPY /src_files/tutorialDocker.conf /etc/apache2/sites-available/tutorialDocker.conf
COPY /src_files/index.html /var/www/html/tutorialDocker/index.html
EXPOSE 80
RUN a2ensite tutorialDocker.conf
RUN apache2ctl -k graceful
CMD apache2ctl -D FOREGROUND

如有任何想法,我们将不胜感激!

docker apache virtualhost
© www.soinside.com 2019 - 2024. All rights reserved.