Apache与Docker Alpine Linux

前端之家收集整理的这篇文章主要介绍了Apache与Docker Alpine Linux前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想用alpine和apache创建一个docker图像.我使用tini作为“init”系统.它工作,直到我分离并重新连接到容器.连接到容器后,apache退出并且容器停止.我不知道问题是什么.有没有人与docker,alpine和apache有类似的问题?

我的Dockerfile看起来像这样(之前,我使用Alpines包管理器进行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"]
@H_404_7@

输入和输出到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
@H_404_7@

更新:
问题似乎是apache2,当docker连接到容器时接收SIGWINCH(窗口大小更改):

[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
@H_404_7@

Apache滥用信号与apachectl实用程序一起正常关闭服务器.是否有可能阻止此信号,以便它不会被归结为apache?

最佳答案
确实,Apache使用SIGWINCH来触发正常关闭

docker kill ----signal=SIGWINCH apache
@H_404_7@

docker-library/httpd issue 9提到

Even just dropping “-t@H_404_7@” should remove the sending of SIGWINCH@H_404_7@ when the window resizes.

实际上,你只需要-d:见 PR669.
在您的情况下,您已经使用-dit运行映像,因此请检查是否只保留-d可能会有所帮助.

原始问题(在httpd端,而不是docker)在bug id 1212224中描述.

OP Sebi2020确认in the comments

if I don’t connect a tty the signal isn’t send

因此,如果可能,请避免使用-t,如果需要,可以在需要时添加docker exec -t session.

原文链接:https://www.f2er.com/docker/435926.html

猜你在找的Docker相关文章