I have a Docker that contains both php7.2-fpm and nginx. I'm trying to connect nginx to php7.2-fpm though socket but I get error:
[crit] 24#24: *1 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 172.20.0.7, server: , request: "GET /health/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:"
Connecting through TCP works but not socket. Cannot find that file anywhere in the system. I might be doing something wrong, been trying stuff for hours with no luck after searching all over stack overflow. It's not a user permission error.
Here is my nginx.conf
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
Here is my www.conf
;listen = 127.0.0.1:9000
listen = /var/run/php/php7.2-fpm.sock
listen.owner = www-data
listen.group = www-data
Here is my Dockerfile:
#
# Vendor
#
FROM composer:2.0.8 as vendor
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-scripts \
--prefer-dist
#
# PHP
#
FROM php:7.2-fpm
RUN apt-get update
ARG ADDITIONAL_LOCALES="aa_DJ.UTF-8 UTF-8 af_ZA.UTF-8 UTF-8 an_ES.UTF-8 UTF-8 ar_AE.UTF-8 UTF-8 ar_BH.UTF-8 UTF-8 ar_DZ.UTF-8 UTF-8 ar_EG.UTF-8 UTF-8 ar_IQ.UTF-8 UTF-8 ar_JO.UTF-8 UTF-8 ar_KW.UTF-8 UTF-8 ar_LB.UTF-8 UTF-8 ar_LY.UTF-8 UTF-8 ar_MA.UTF-8 UTF-8 ar_OM.UTF-8 UTF-8 ar_QA.UTF-8 UTF-8 ar_SA.UTF-8 UTF-8 ar_SD.UTF-8 UTF-8 ar_SY.UTF-8 UTF-8 ar_TN.UTF-8 UTF-8 ar_YE.UTF-8 UTF-8 ast_ES.UTF-8 UTF-8 be_BY.UTF-8 UTF-8 bg_BG.UTF-8 UTF-8 br_FR.UTF-8 UTF-8 bs_BA.UTF-8 UTF-8 ca_AD.UTF-8 UTF-8 ca_ES.UTF-8 UTF-8 ca_FR.UTF-8 U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"
# GD, Imagick
RUN apt-get install -y --no-install-recommends \
locales locales-all \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libmagickwand-dev \
nginx \
imagemagick \
cron \
ghostscript && \
#
# Locales
#
echo '' >> /usr/share/locale/locale.alias \
&& temp="${ADDITIONAL_LOCALES%\"}" \
&& temp="${temp#\"}" \
&& for i in ${temp}; do sed -i "/$i/s/^#//g" /etc/locale.gen; done \
&& locale-gen && \
#
# PHP Extensions
#
export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-configure intl && \
docker-php-ext-install pdo pdo_mysql gd intl && \
pecl install imagick && \
docker-php-ext-enable imagick intl
COPY . /var/www/html/
COPY --from=vendor /app/vendor/ /var/www/html/vendor/
COPY ./docker/php.ini /usr/local/etc/php/php.ini
COPY ./docker/nginx.conf /etc/nginx/sites-enabled/default
COPY ./docker/www.conf /usr/local/etc/php-fpm.d/www.conf
COPY ./docker/image-magic-policy.xml /etc/ImageMagick-6/policy.xml
COPY ./docker/app-cron.txt /app-cron.txt
COPY ./docker/entrypoint.sh /
EXPOSE 80
ENTRYPOINT ["sh", "/entrypoint.sh"]
And this is my entrypoint:
#!/bin/bash
crontab /app-cron.txt &
cron -f &
service nginx start &
docker-php-entrypoint php-fpm