5
我想創建一個Dockerfile,它將自動啓動Apache。沒有任何工作。但是,如果我登錄容器並運行service apache2 start
它的工作。爲什麼我不能從Dockerfile運行該命令?如何在ubuntu docker容器中自動啓動apache2?
FROM ubuntu
# File Author/Maintainer
MAINTAINER rmuktader
# Update the repository sources list
RUN apt-get update
# Install and run apache
RUN apt-get install -y apache2 && apt-get clean
#ENTRYPOINT ["/usr/sbin/apache2", "-k", "start"]
#ENV APACHE_RUN_USER www-data
#ENV APACHE_RUN_GROUP www-data
#ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD service apache2 start
它沒有工作。我複製並粘貼你的Dockerfile,運行'docker build -t my_img .',運行'docker run -ti -p80:80 --name'test2'my_img/bin/bash',但apache沒有運行。 –
我試過這種方法,它適用於我。嘗試從您的命令中刪除'/ bin/bash' –
它工作正常!這是否適用於多種服務? –