0

I have a docker container running a Centos 7 image. All it needs to do is run a simple Apache2 server. When the container starts it exits immediately with:

AH00526: Syntax error on line 119 of /etc/httpd/conf/httpd.conf:
DocumentRoot '/var/www/html' is not a directory, or is not readable

I did some basic checks:

  • Folder exists
  • Permissions are ```rwx r_x r_x root root```` for each folder /var/www/html
  • Tried chown -R apache /var/www (no straw shall remain unclutched!)
  • SELinux is disabled (... or is it?)

When I enter the container with a bash entry point, I can then start apache as root with /sbin/httpd -D FOREGROUND and everything works as expected.

So I think its almost certainly a permissions thing. Googling found many pages with my error e.g. Apache restart causes DocumentRoot must be a directory, even though it is a directory and there seem to be no privilege issues This particular page closely describes what I am getting and the solution in almost every page is configure SELinux. However SELinux is disabled. Even in that link there is comment from the OP

My version of linux isn't Security Enhanced Linux, so without understanding I tried it anyway: no effect.

Yet they accepted the solution which was configure SELinux.

I think I am missing something, almost certainly SELinux related, but I can't figure it out. The docker image has the following (distinct lack of) SELinux settings:

  • /etc/selinux contains only semanage.conf and tmp/ (empty)
  • /usr/sbin contains no se* executables
  • rpm -qa | grep selinux
    • libselinux-2.5-12.el7.x86_64
  • /etc/sysconfig/selinux does not exist
    • So in the Dockerfile I tried RUN echo "SELINUX=disabled" > /etc/sysconfig/selinux
  • doing yum install -y policycoreutils installs sestatus in /usr/sbin. Running sestatus gives
    • SELinux status: disabled
    • With or without /etc/sysconfig/selinux

It really looks like SELinux is disabled, yet the error looks so much like it is enabled.

Martin
  • 2,316
  • 1
  • 28
  • 33
  • What Docker image are you running? If it's a custom image, can you share your Dockerfile? Can you also include the `docker run` command you're using to start the image? – David Maze Aug 31 '18 at 18:08
  • Thank you! You have pushed me in the correct direction. I use docker-compose to launch a number of related services. I am moving these services from our ubuntu base to the customer's centos base, but I had not updated the volumes mappings in docker-compose.yml. Changing them from deb to centos paths has solved the issue. – Martin Aug 31 '18 at 18:55

1 Answers1

1

The issue in this case was due to the way the container was launched.

I use docker-compose to launch this particular container but the paths for the volume mapping were incorrect.

I am still not sure why this causes apache to fail to start in the way it does but correcting the paths fixed the issue.

Martin
  • 2,316
  • 1
  • 28
  • 33