![無法從我的本機(ubuntu os)存取docker上的apache2](https://rvso.com/image/1592160/%E7%84%A1%E6%B3%95%E5%BE%9E%E6%88%91%E7%9A%84%E6%9C%AC%E6%A9%9F%EF%BC%88ubuntu%20os%EF%BC%89%E5%AD%98%E5%8F%96docker%E4%B8%8A%E7%9A%84apache2.png)
我正在嘗試從本地主機存取安裝在 docker 上的 apache,但無法存取。以下是 dockerfile 內容
RUN apt-get update
RUN apt-get -y install apache2
WORKDIR /var/www/html/
RUN rm -f index.html
RUN touch index.html
RUN echo "welcome" > index.html
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
EXPOSE 8080
CMD ["apachectl", "-D", "FOREGROUND"]
我使用的是ubuntu 18.04。使用此命令來運行 dockerdocker run -dit -p 8080:8080 imageName
容器已啟動並正在運行,並且還指向端口
0.0.0.0:8080->8080/tcp
我可以在沒有 docker 的情況下存取本機上的 apache2,但無法存取安裝在 docker 容器上的 apache2。
請幫忙 :)