我尝试运行php:apache容器。然后我应用虚拟主机设置并退出容器 bash 我使用了docker restart <containerid>
但我无法启动。然后我用docker logs <containerid>
检查了日志,它说你在 000-default.conf 中有一个语法
现在这是我的问题:如果我无法启动容器,如何连接容器 bash 并打开 000-default.conf 并修复语法错误?还有其他办法吗?
以下是日志输出:
C:UsersUtku>docker logs bb
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
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
[Sat Mar 23 01:05:26.411235 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.16 configured -- resuming normal operations
[Sat Mar 23 01:05:26.411274 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Sat Mar 23 01:05:37.388586 2019] [autoindex:error] [pid 16] [client 172.17.0.1:40982] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
localhost:80 172.17.0.1 - - [23/Mar/2019:01:05:37 +0000] "GET / HTTP/1.1" 403 501 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
localhost:80 172.17.0.1 - - [23/Mar/2019:01:05:37 +0000] "GET /favicon.ico HTTP/1.1" 404 500 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
localhost:80 172.17.0.1 - - [23/Mar/2019:01:06:55 +0000] "GET / HTTP/1.1" 200 286 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
[Sat Mar 23 01:07:53.847828 2019] [mpm_prefork:notice] [pid 1] AH00169: caught SIGTERM, shutting down
AH00526: Syntax error on line 35 of /etc/apache2/sites-enabled/000-default.conf:
Invalid command 'sadasd', perhaps misspelled or defined by a module not included in the server configuration
编辑:docker cp
也应该适用于停止的容器,您可以将配置文件从容器中复制出来,对其进行编辑,然后复制回来。
是的,但您需要从此容器创建映像并运行它:
- 使用
docker ps -a
查找失败容器的 ID,例如:d391b29f5526
。 - 运行
docker commit d391b29f5526 test-image
以从此容器创建映像。 -
docker run -it --entrypoint bash test-image
并进行编辑。 - 将从步骤 3 中创建的容器提交到映像并运行它。
尝试以下操作:
docker cp bb:/etc/apache2/sites-enabled/000-default.conf /tmp/000-default.conf
现在,编辑您的/tmp/000-default.conf(在您的 docker 主机上(并删除它 sadasd
在您的第 35 行上,如日志中所述;
编辑后,将文件复制回容器:
docker cp /tmp/000-default.conf bb:/etc/apache2/sites-enabled/000-default.conf
如果您的 conf 文件没有错误,现在您应该能够重新启动容器。