Apache with Docker Alpine Linux

I want to create a docker image with alpine and apache. I use tini as an "init" -System. It works until I disconnect and join the container. After attaching to the container, Apache exits and the container stops. I do not know what's the problem. Has anyone had problems with docker, alpine and apache?

My Dockerfile looks like this: (I used to use Alpines package manager for tini)

FROM alpine
ENV TINI_VERSION v0.16.1
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /sbin/tini
RUN chmod +x /sbin/tini
RUN apk add --no-cache apache2 \
   && mkdir -p /run/apache2 \
   && ln -sf /dev/stdout /var/log/apache2/access.log \
   && ln -sf /dev/stderr /var/log/apache2/error.log
EXPOSE 80
ENTRYPOINT ["/sbin/tini", "-vvv", "-g", "--"]
CMD ["/usr/sbin/httpd", "-f", "/etc/apache2/httpd.conf", "-DFOREGROUND"]

Logging in and out of docker cli:

~/Desktop/docker_test@laptop-sebi
$ docker run -itd test1
a793bad5d4350f58893909f1552c9f2978d8e2952960ac667f8dcb2bf7a3516e

~/Desktop/docker_test@laptop-sebi
$ docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             
STATUS              PORTS               NAMES
a793bad5d435        test1               "/sbin/tini -vvv -..."   12 seconds 
ago      Up 11 seconds       80/tcp              sharp_neumann

~/Desktop/docker_test@laptop-sebi
$ docker attach a7
[DEBUG tini (1)] Received SIGCHLD
[DEBUG tini (1)] Reaped child with pid: '5'
[INFO  tini (1)] Main child exited normally (with status '0')
[TRACE tini (1)] No child to wait
[TRACE tini (1)] Exiting: child has exited

Update: It seems that the problem is apache2, which gets SIGWINCH (window resizing), and the docker is attached to the container:

[Sun Oct 15 12:13:24.592575 2017] [mpm_prefork:notice] [pid 5] AH00170: caught SIGWINCH, shutting down gracefully
[DEBUG tini (1)] Received SIGCHLD
[DEBUG tini (1)] Reaped child with pid: '5'
[INFO  tini (1)] Main child exited normally (with status '0')
[TRACE tini (1)] No child to wait
[TRACE tini (1)] Exiting: child has exited

Apache apachectl . , apache?

+6
2

, Apache SIGWINCH, :

docker kill ----signal=SIGWINCH apache

docker-library/httpd issue 9

"-t" SIGWINCH .

-d: . PR669.
-dit, , -d.

( httpd, ) 1212224.

OP Sebi2020 :

tty,

, , -t , , docker exec -t , tty.

+2

CMD exec form shell form, /bin/sh -c <...> :

CMD /usr/sbin/httpd -f /etc/apache2/httpd.conf -DFOREGROUND 
# or use ENTRYPOINT with the same shell form

PID 1 Unix .

( ), attach exec -it stop , .

:
http://www.johnzaccone.io/entrypoint-vs-cmd-back-to-basics/
( 3)
https://docs.docker.com/engine/reference/builder/#cmd https://docs.docker.com/engine/reference/builder/#shell-form-entrypoint-example

+1

All Articles