im trying to set up a Laravel project.
The setup is:
- Centos
- Apache
- MySql
I have split containers for App, Web, Database
And app container is fail to run 🙁
This is my docker-compose.yml
:
version: '2'
services:
# The Application
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
environment:
- "DB_PORT=3306"
- "DB_HOST=database"
# The Web Server
web:
build:
context: ./
dockerfile: web.dockerfile
working_dir: /var/www
volumes_from:
- app
ports:
- 8080:80
# The Database
database:
image: mysql:5.6
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=homestead"
- "MYSQL_USER=homestead"
- "MYSQL_PASSWORD=secret"
- "MYSQL_ROOT_PASSWORD=secret"
ports:
- "33061:3306"
volumes:
dbdata:
This is my app.dockerfile
FROM centos:7.5.1804
RUN yum update -y
RUN yum install epel-release http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils -y &&
yum-config-manager --enable remi-php72 &&
yum update -y
RUN yum install vim wget curl unzip
php php-json php-gd php-mbstring php-pdo php-xml php-mysqlnd -y
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&
php composer-setup.php --install-dir=/usr/local/bin --filename=composer &&
rm -rf composer-setup.php
RUN curl -sL https://rpm.nodesource.com/setup_8.x | bash - &&
yum install nodejs -y
RUN yum clean all
EXPOSE 80
# Keep container active
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
And this is my web.dockerfile:
FROM httpd:2.4
COPY httpd.conf /etc/httpd/conf/httpd.conf
When I run docker-compose up
shows some messages:
app_1 | AH00526: Syntax error on line 119 of
/etc/httpd/conf/httpd.conf: app_1 | DocumentRoot ‘/var/www/html’
is not a directory, or is not readableadsist-docker_app_1 exited with code 1
2
Answers
It seems that your app will be deployed in
/var/www/
while you configure Apache to use/var/www/html/
as a document root so while starting Apache it checks first for configured document root but it can’t find it so it fails to start and generate the mentioned error.So you have to decide to change document root in httpd.conf to point to
/var/www/
or configure docker-compose file to work and mount volumes to/var/www/html
./var/www/html
set as apache documentroot is popular in most linux distributions, but this is not the thing inhttpd
docker image. Additional, even you modify http.conf to use/var/www/html
, you still should mount to/var/www/html
, not/var/www
.And back to the
httpd
image, you could see next:So, if you do not change default settings, you should mount your host’s files to
/usr/local/apache2/htdocs
to serve your service.And more,
COPY httpd.conf /etc/httpd/conf/httpd.conf
in yourDockerfile
is also not correct, it should beCOPY httpd.conf /usr/local/apache2/conf/httpd.conf
.