如何在不终止docker容器的情况下重启apache2? [英] How to restart apache2 without terminating docker container?

查看:278
本文介绍了如何在不终止docker容器的情况下重启apache2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 php docker容器作为基础,:

I am using as a base the php docker container with the tag:

php:5.6-apache

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

When I try to restart the apache2 inside the container, the container stops:

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

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

How to restart apache2 without stopping the container?

在将更改放入dockerfile之前,我想使用容器并对其进行自定义.我想安装一些扩展程序,为了使它们正常工作,我需要重新启动apache才能使更改生效.

I want to play around with the container and customize it, before I put my changes into the dockerfile. I want to install some extension and for them to work I need to restart apache for the changes to take effect.

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

This is the log file via:

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.

If you use apache as the primary service to keep your running container, you can NOT reboot it. Simply because you built the image and sets the CMD with it.

CMD的主要目的是为执行中的容器提供默认值.这些默认值可以包含可执行文件,也可以省略可执行文件,在这种情况下,您还必须指定ENTRYPOINT指令.

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.

尝试重新加载而不重启服务:

Try to reload without restart a service:

/etc/init.d/apache2 reload

这篇关于如何在不终止docker容器的情况下重启apache2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆