php - 如何在不终止 docker 容器的情况下重新启动 apache2?

我使用 php docker container 作为基础带有标签:

php:5.6-apache

当我尝试重新启动容器内的 apache2 时,容器停止:

root@phalconapp:/var/www/html# service apache2 restart
Restarting web server: apache2Terminated
root@phaclonapp:/var/www/html#
me@myLocalComputer:

如何在不停止容器的情况下重启apache2?

在将更改放入 dockerfile 之前,我想尝试使用容器并对其进行自定义。我想安装一些扩展并让它们工作我需要重新启动 apache 以使更改生效。

这是通过以下方式的日志文件:

Attaching to dltasklight_phlaconapp_1
phlaconapp_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
phlaconapp_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
phlaconapp_1 | [Mon May 30 10:19:24.556154 2016] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/5.6.22 configured -- resuming normal operations
phlaconapp_1 | [Mon May 30 10:19:24.556181 2016] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
phlaconapp_1 | [Mon May 30 10:21:11.754993 2016] [mpm_prefork:notice] [pid 1] AH00169: caught SIGTERM, shutting down
dltasklight_phlaconapp_1 exited with code 0

最佳答案

如果您使用 apache 作为主要服务来保持正在运行的容器,则不能重新启动它。仅仅因为您构建了图像并使用它设置了 CMD。

The main purpose of a CMD is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well.

尝试在不重启服务的情况下重新加载:

/etc/init.d/apache2 reload

https://stackoverflow.com/questions/37523338/

相关文章:

python - 为什么人们在 docker 容器中创建 virtualenv?

docker - boot2docker 存储的 docker 镜像在哪里?

amazon-web-services - 如何将 Kubernetes 日志发送到 AWS Clo

windows - docker 警告 : failed to get default regist

docker - 如何增加 kubernetes 容器的 shm 大小(--shm-size 相当于

string - docker-compose.yml invalid : app. build c

docker - 从 Dockerfile 构建时如何访问本地文件?

docker - 中间容器是如何形成的?

docker - 在 Dockerbuild 文件中使用 docker-compose 环境变量

mysql - 使用 docker-compose 来创建 MySQL 模式/数据库