无法在docker容器中启动apache2
我的Dockerfile:无法在docker容器中启动apache2,docker,apache2,Docker,Apache2,我的Dockerfile: FROM ubuntu:latest RUN apt-get update RUN apt-get install -y apache2 RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf CMD ["/usr/sbin/apache2ctl","start"] 但当我构建映像并运行容器时,我会检查apache状态并获得: root@79074bf56be4:/# service
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y apache2
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
CMD ["/usr/sbin/apache2ctl","start"]
但当我构建映像并运行容器时,我会检查apache状态并获得:
root@79074bf56be4:/# service apache2 status
* apache2 is not running
如果我在容器内手动启动它,它会工作:
root@79074bf56be4:/# /usr/sbin/apache2ctl start
root@79074bf56be4:/#
root@79074bf56be4:/# service apache2 status
* apache2 is running
root@79074bf56be4:/#
我做错了什么?如何使apache2在容器启动时自动启动?对不起,我没有谷歌搜索好 通过将CMD行替换为以下内容解决:
CMD apache2ctl -D FOREGROUND
和cuntainer运行此命令:
docker run --detach my_image
您用来启动容器的命令是什么?