我有以下 Dockerfile:
FROM php:8.0-apache
WORKDIR /var/www/html
EXPOSE 80
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
rm -rf /etc/apache2/sites-enabled/000-default.conf && \
service apache2 restart
我以这种方式在该图像上运行容器:
sudo docker run -d --name apache2-container -e TZ=UTC -p 8080:80 -v /home/xxx/www:/var/www/html -v /home/xxx/apache2.conf:/etc/apache2/apache2.conf my_image
/home/xxx/apache2.conf 是:
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
ErrorLog ${APACHE_LOG_DIR}/error.log
HostnameLookups Off
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /srv/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ServerName localhost
<VirtualHost *:80>
DocumentRoot /var/www/html
</VirtualHost>
创建镜像或创建容器期间没有任何错误,但是当我尝试访问 localhost:8080 时,网站加载了 15 分钟,没有任何结果。
我做错了什么? 谢谢
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我无法发表评论,但这里有几个调试问题: