大网数据广告活动
服务器运维问答

Container restart misses /run until I exec bash

· 52CE 我爱测

I'm having a weird error on a custom docker image. The host system is centos 7.4 with Docker 17.12.0-ce while the image is based on centos 7.2 with apache and has a custom app running on cgi. When a new container is created it wo…

问题原文

原帖链接 · Juanma · CC BY-SA 3.0

I'm having a weird error on a custom docker image. The host system is centos 7.4 with Docker 17.12.0-ce while the image is based on centos 7.2 with apache and has a custom app running on cgi. When a new container is created it works OK but, when the container is restarted (either from the restart=always flag or manually), it keeps restarting the apache bin at the end of the script run by CMD.

Looking at the apache logs (which are in a volume), it shows these lines with every apache restart:

[auth_digest:error] [pid 19] (17)File exists: AH01762: Failed to create shared memory segment on file /run/httpd/authdigest_shm.19
[auth_digest:error] [pid 19] (17)File exists: AH01760: failed to initialize shm - all nonce-count checking, one-time nonces, and MD5-sess algorithm disabled
[:emerg] [pid 19] AH00020: Configuration Failed, exiting

Googling the error codes, it seems like a problem with /run/httpd folder so I decide to exec a bash terminal to see if there's any problem with it and, at the precise moment I bash into the container, the errors stop, I get these lines:

[auth_digest:notice] [pid 34] AH01757: generating secret for digest authentication ...
[lbmethod_heartbeat:notice] [pid 34] AH02282: No slotmem from mod_heartmonitor
[core:warn] [pid 34] AH00098: pid file /run/httpd/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[mpm_prefork:notice] [pid 34] AH00163: Apache/2.4.6 (CentOS) mod_perl/2.0.10 Perl/v5.16.3 configured -- resuming normal operations
[core:notice] [pid 34] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

and apache starts answering as nothing happened.

I've tested this behavior several times, it's not time-dependant (it can be 5 minutes or 1 hour with the error messages, they will stop as soon as I log in).

So, my questions are:

  1. What can my bash login trigger that solve the problem?
  2. How can I replicate it in the script run by CMD?

Kind regards.

PS: sorry if this has been asked before, I've been having a really difficult time searching for a problem with docker and "/run" as google ignores the slash.

已采纳解答

原帖链接 · Juanma · CC BY-SA 3.0

So, via trial and error I've found a way to apparently solve this problem but I'm entirely lost on why this happens.

I've added at the beginnig of the script run by CMD an instruction to delete the contents of /run/httpd:

1 #!/bin/bash
2
3 rm -rf /run/httpd/*
4
5 [... continue execution as before ...]

There seems to be no drawback from this measure, so I'll stick to it.

I'll still be more than happy if anyone can provide an explanation of this behavior.

Kind regards

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-01-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。