简体   繁体   English

Docker容器无法启动

[英]Docker container fails to start

I have this container: 5.6.21-apache from https://hub.docker.com/_/php/ 我有这个容器:5.6.21-apache来自https://hub.docker.com/_/php/

I have installed all I need and my application but I made a mistake doing something wrong with Apache configs. 我已经安装了所有我需要的和我的应用程序,但我犯了一个错误,做了一些错误的Apache配置。

When I try start my container I get this message: 当我尝试启动我的容器时,我收到以下消息:

docker start -ai my-container docker start -ai my-container

[Mon May 02 19:46:33.358838 2016] [core:warn] [pid 1] AH00111: Config variable ${APACHE_LOG_DIR} is not defined [Mon May 02 19:46:33.365305 2016] [core:warn] [pid 1] AH00111: Config variable ${APACHE_LOG_DIR} is not defined AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. [Mon May 02 19:46:33.358838 2016] [core:warn] [pid 1] AH00111:配置变量$ {APACHE_LOG_DIR}未定义[Mon May 02 19:46:33.365305 2016] [core:warn] [pid 1 ] AH00111:未定义配置变量$ {APACHE_LOG_DIR} AH00558:apache2:无法使用172.17.0.2可靠地确定服务器的完全限定域名。 Set the 'ServerName' directive globally to suppress this message (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/${APACHE_LOG_DIR}/' for main error log AH00014: Configuration check failed 全局设置'ServerName'指令以禁止显示此消息(2)没有此类文件或目录:AH02291:无法访问目录'/ etc / apache2 / $ {APACHE_LOG_DIR} /'主错误日志AH00014:配置检查失败

How can I solve this? 我怎么解决这个问题? I want drop this configs. 我想放弃这个配置。 I can't just lose this container. 我不能丢失这个容器。

Since you haven't given enough information to go on, I'm just going to guess. 由于你没有提供足够的信息继续下去,我只是猜测。 Feel free to add more info to your questions so that it will be easier to help you. 您可以随意在问题中添加更多信息,以便更轻松地为您提供帮助。

If you search your apache config file and look for APACHE_LOG_DIR , it will probably point to your issue. 如果您搜索apache配置文件并查找APACHE_LOG_DIR ,它可能会指向您的问题。

This line in the logs is interesting: 日志中的这一行很有意思:

Cannot access directory '/etc/apache2/${APACHE_LOG_DIR}/' 无法访问目录'/ etc / apache2 / $ {APACHE_LOG_DIR} /'

Not sure why you would have a log directory under /etc/apache2, but look in that directory to see what you have in there, and set APACHE_LOG_DIR accordingly. 不确定为什么在/ etc / apache2下会有一个日志目录,但是查看该目录以查看其中的内容,并相应地设置APACHE_LOG_DIR

Another thing you can try is to do the following 您可以尝试的另一件事是执行以下操作

docker commit (container name or Id) myimage

docker run -it myimage /bin/bash

Then commit changes again to create the fixed image and try to start it up like normal. 然后再次提交更改以创建固定图像并尝试像平常一样启动它。

docker commit (container Id or name) myimage2

docker run -d -p 80:80 myimage2

Basically save the current container state as an image so you can start it up in a shell and fix the issues. 基本上将当前容器状态保存为图像,以便您可以在shell中启动它并修复问题。 Then once you have fixed the issues you can create a new image and use that to run your container. 然后,一旦解决了问题,就可以创建新图像并使用它来运行容器。

I usually avoid this pain by not making changes directly in the containers, I only make changes in my dockerfiles and then when I need to make, I change the dockerfile. 我通常不通过直接在容器中进行更改来避免这种痛苦,我只在dockerfiles中进行更改,然后当我需要进行更改时,我更改了dockerfile。 If there is an issue, I just need to fix the dockerfile, and the containers don't get in this bad state. 如果有问题,我只需要修复dockerfile,容器就不会处于这种糟糕的状态。

In my case after rebooting computer (or sleeping/restarting system) I have a problem with starting a container. 在我重新启动计算机(或睡眠/重启系统)后,我遇到启动容器的问题。 Before run start I use docker exec command. 在运行开始之前,我使用docker exec命令。 Example: 例:

docker exec -ti CONTAINER_NAME /bin/bash

(Have a message that container is not running and then) (有一条消息说容器没有运行然后)

docker start CONTAINER_NAME

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM