我有以下 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 分鐘,沒有任何結果。
我做錯了什麼? 謝謝
P粉9869374572024-02-04 10:28:59
我無法發表評論,但這裡有幾個調試問題: