Dockerfile Alpine Linux apache2 ENTRYPOINT httpd starts but container quits with no error message

Hi,

I created an image using a Dockerfile.
I started the container using the command

docker run container name

The container started successfully and httpd started with a warning message for ServerName and quit.
If I manually follow the steps in the Dockerfile the httpd runs without quitting.
There is no information in the error logs.
Providing the contents of the Dockerfile

Thank you :slight_smile:

Siju

#alpine-apache2
FROM alpine
MAINTAINER sgeorge.ml2@gmail.com

RUN apk update
RUN apk upgrade
RUN apk add --no-cache apache2

RUN mkdir /run/apache2

WORKDIR /var/log/apache2
RUN touch access.log
RUN touch error.log
RUN chown root.wheel access.log
RUN chown root.wheel error.log
RUN chmod 0644 access.log
RUN chmod 0644 error.log

EXPOSE 80

ENTRYPOINT ["/usr/sbin/httpd"]

I found the answer :slight_smile:

You have to start it in the foreground with the option “daemon off” in nginx,conf

https://docs.docker.com/v1.11/engine/reference/run/#detached-vs-foreground

The following Dockerfile just does it right

#
# debian-stretch-nginx

# Base Image
FROM debian

LABEL "vendor"="BroadTech Innovations PVT LTD"
LABEL "vendor.url"="http://www.broadtech-innovations.com/"
LABEL "maintainer"="sgeorge.ml@gmail.com"

# Update Repository Index
RUN apt-get update

# Upgrade image and apply security updates
RUN DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -yq 

# Install Nginx
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq nginx

# Remove retrieved package files from local cache
RUN apt-get clean

# Donot daemonize Nginx
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf

# Open port to access Nginx
EXPOSE 80

# Run Nginx when container starts
CMD ["/usr/sbin/nginx"]

# --END--#

And for apache you need to run it with “-D FOREGROUND” option

https://deninet.com/blog/1585/docker-scratch-part-3-entrypoints-and-ports