Docker容器报错处理:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message

容器2022-08-11
Docker容器报错处理:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message-下一朵云

故障描述:宿主机Centos7下安装docker服务,有一个提供web服务的容器,已经设置容器跟随docker服务器自启动,但是每当重启Centos7后,其他容器正常,唯有这一个容器的web服务不正常,无法访问。

解决办法:在apache的默认配置文件内增加 ServerName IP

Docker容器报错处理:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message-下一朵云

故障处理:重启CentOS后查看不正常的容器日志:

$ docker logs --since 30m CONTAINER_ID //查看30分钟内的日志
Docker容器报错处理:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message-下一朵云

1.如上图可见容器内apache有报错:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message

查看出问题的容器的IP,确定容器IP为172.17.0.5

$ docker inspect CONTAINER_ID | grep IPAddress
Docker容器报错处理:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message-下一朵云

2.此报错可能是因为apache的配置文件没有定义 ServerName 这一项,需要添加:

ServerName 172.17.0.5

$ odcker exec -it CONTAINER_ID bash  //进入容器
$ cat /etc/apache2/sites-enable/000-defalut.conf //查看配置文件
Docker容器报错处理:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message-下一朵云

3.如上图 #ServerName 是被注释的,问题处理就很简单了,直接取消注释,新增一条:

ServerName 172.17.0.5

4.但是容器里边没有vim编辑器,怎么办?

Docker容器报错处理:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message-下一朵云

直接从容器中拷贝文件到宿主机,然后在宿主机修改完成后拷贝进容器

$docker cp host_path containerID:container_path  //从主机复制到容器
$docker cp containerID:container_path host_path  //从容器复制到主机

复制完成后,注意在容器中检查文件权限配置是否和之前一致

Docker容器报错处理:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.5. Set the ‘ServerName’ directive globally to suppress this message-下一朵云

检查一致,Ctrl+d退出容器,重启容器

$ docker restart CONTAINER_ID

5.容器web服务正常访问!重启宿主机,之前的故障消失。

附:docker查看日志记录

 命令格式:
 $ docker logs [OPTIONS] CONTAINER
   Options:
         --details        显示更多的信息
     -f, --follow         跟踪实时日志
         --since string   显示自某个timestamp之后的日志,或相对时间,如42m(即42分钟)
         --tail string    从日志末尾显示多少行日志, 默认是all
     -t, --timestamps     显示时间戳
         --until string   显示自某个timestamp之前的日志,或相对时间,如42m(即42分钟)
 例子:
 查看指定时间后的日志,只显示最后100行:
 $ docker logs -f -t --since="2018-02-08" --tail=100 CONTAINER_ID
 查看最近30分钟的日志:
 $ docker logs --since 30m CONTAINER_ID
 查看某时间之后的日志:
 $ docker logs -t --since="2018-02-08T13:23:37" CONTAINER_ID
 查看某时间段日志:
 $ docker logs -t --since="2018-02-08T13:23:37" --until "2018-02-09T12:23:37" CONTAINER_ID
版权声明:本文为下一朵云发布文章,转载请附上原文出处链接和本声明。
本文链接:https://www.orcy.net.cn/775.html

​ 广告:HCIE-Security认证课程辅导资料(付费)

6 条评论

  • 头像
    wyn
    2022-07-06

    还有一种是开了vpn,全都对外访问不了,报500

  • 头像
    9527
    2022-01-10

    docker cp -L containerID:container_path host_path

  • 头像
    两襟晚照
    2020-06-23

    容器启动ip地址不固定,这种方法每次初次启动都要改配置文件为容器当前ip?有没有不用配具体地址而是配变量的方法呢?

    • 头像
      pony
      2020-06-30

      使用user-defined网络,创建容器的时候可以指定固定的IP给容器

  • 头像
    slena
    2020-05-09

    2步骤下面,docker exec -it CONTAINER_ID bash //进入容器
    这里容器没有启动,进不去啊。

    • 头像
      pony
      2020-05-14

      docker ps 看一下正在运行的容器,上边会有ID显示 ,将“CONTAINER_ID”替换为你的容器ID。

发表评论

电子邮件地址不会被公开。 必填项已用*标注