apche无法在docker容器中启动

时间:2017-10-01 14:05:37

标签: apache ubuntu docker

我在dockerfile的帮助下创建了一个docker容器。

FROM ubuntu:12.04

RUN apt-get update && apt-get install -y apache2 && apt-get clean

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2

EXPOSE 80

CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]

我已经从中创建了一个容器,并且它已成功运行。当我停止docker服务并再次启动容器时。容器启动成功,但apache无法启动

[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
4283f23b1785        ubuntu/webserver    "/usr/sbin/apache2..."   20 hours ago        Up 8 minutes        0.0.0.0:80->80/tcp   stoic_swartz

所以,我登录到容器并检查了apache2状态

[root@localhost ~]# docker exec -it stoic_swartz bash
root@4283f23b1785:/# /etc/init.d/apache2 status
Apache2 is NOT running.
root@4283f23b1785:/# /etc/init.d/apache2 start
 * Starting web server apache2                                                                                                                                apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2 for ServerName
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

为什么apache无法启动?

1 个答案:

答案 0 :(得分:0)

错误在那里:

Unable to open logs

可能你以root身份运行所有东西,而apache期望用户www-data成为文件的所有者;)