Hello first time dockerize my project.
Below are my files:
docker-compose.yml
version: "3"
services:
apache:
build:
context: .
dockerfile: apache2/Dockerfile
container_name: markitplace-php
ports:
- '8080:80'
volumes:
- ./www/html:/var/www/html
- ./apache2/configs:/etc/apache2/sites-available
networks:
- internal
depends_on:
- php
- db
db:
image: mysql:5.7.22
container_name: db
restart: unless-stopped
tty: true
ports:
- "3307:3306"
environment:
MYSQL_DATABASE: markitplace
MYSQL_ROOT_PASSWORD: admin0101
volumes:
- db:/var/lib/mysql
networks:
- internal
php:
build:
context: .
dockerfile: php/Dockerfile
networks:
- internal
volumes:
- ./www/html/:/var/www/html/
- ./logs/php.log:/var/log/fpm-php.www.log
depends_on:
- db
networks:
internal:
driver: bridge
volumes:
db:
apache2/Dockerfile
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y apache2 && \
apt-get install -y wget && \
a2enmod rewrite && \
a2dissite 000-default.conf
RUN wget https://mirrors.edge.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb
RUN dpkg -i libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb
# Install FastCGI module
RUN apt-get update && apt-get install -y libapache2-mod-fastcgi
# Enable FastCGI module
RUN a2enmod fastcgi
RUN a2enmod actions
COPY apache2/configs/php7-fcgi.conf /etc/apache2/conf-available/php7-fcgi.conf
RUN a2enconf php7-fcgi
RUN a2enmod proxy_fcgi setenvif
COPY apache2/configs/docker.markitplace.local.conf /etc/apache2/sites-available/docker.markitplace.local.conf
RUN a2enmod headers
RUN a2ensite docker.markitplace.local.conf
WORKDIR /var/www/html
#COPY html/ /var/www/html/
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
apache2/configs/docker.markitplace.local.conf
<VirtualHost *:80>
ServerName docker.markitplace.local
ServerAlias www.docker.markitplace.local
DocumentRoot /var/www/html/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://php:9000"
</FilesMatch>
<Directory "/var/www/html/public">
AllowOverride All
</Directory>
</VirtualHost>
ServerName docker.markitplace.local
apache2/configs/php7-fcgi.conf
<IfModule mod_fastcgi.c>
AddHandler php7-fcgi .php
Action php7-fcgi /php7-fcgi
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
FastCGIExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php-fpm.sock -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule>
php/Dockerfile
FROM php:7.0.33-fpm-alpine
RUN apk add --no-cache bash mysql-client msmtp perl wget procps shadow libzip libpng libjpeg-turbo libwebp freetype icu
RUN apk add --no-cache --virtual build-essentials \
icu-dev icu-libs zlib-dev g++ make automake autoconf libzip-dev \
libpng-dev libwebp-dev libjpeg-turbo-dev freetype-dev && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp && \
docker-php-ext-install gd && \
docker-php-ext-install mysqli && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install intl && \
docker-php-ext-install opcache && \
docker-php-ext-install exif && \
docker-php-ext-install zip && \
apk del build-essentials && rm -rf /usr/src/php*
RUN apk --no-cache add git curl zlib-dev libpng-dev
RUN echo 'listen = /var/run/php-fpm.sock\n' > /usr/local/etc/php-fpm.d/zz-socket.conf
# Composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer && \
chmod +x /usr/local/bin/composer && \
composer self-update
RUN command -v composer
RUN php -v
RUN composer --version
#RUN node -v
#RUN npm -v
#
# Configure PHP
#COPY config/php.ini /usr/local/etc/php/
# Set working directory
WORKDIR /var/www/html
# Add application
#COPY www/html /var/www/html
# Give permissions
# RUN composer install
COPY ./www/html/ /var/www/html/
RUN chown -R www-data:www-data /var/www/html/ && chmod -R 777 /var/www/html/ && chmod -R 777 storage && chmod -R 777 bootstrap/cache storage
RUN php artisan config:clear
#RUN composer dump-autoload
RUN composer install
RUN composer dump-autoload
# Expose port 9000 and start PHP-FPM server
EXPOSE 9000
CMD ["php-fpm"]
Can anyone please help me out what I am doing wrong. When access localhost:8000 below error is showing up in the logs of apache2
AH01079: failed to make connection to backend: httpd-UDS
(2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.0-fpm.sock (*) failed