I am trying to test my php server to run the application before deploying it on AWS (first time) Doesn’t work for me locally with my docker configuration.
I use:
docker build -f docker-configs/php/Dockerfile -t php-service .
docker run -p 9000:9000 php-service
and there is no response from localhost:9000
Logs show:
[23-Aug-2023 08:37:53] NOTICE: fpm is running, pid 1
[23-Aug-2023 08:37:53] NOTICE: ready to handle connections
but can’t connect.
My Dockerfile
FROM php:8.2-fpm
RUN apt-get update && apt-get install -y
git
unzip
libicu-dev
libpq-dev
wget
&& apt-get install -y
librabbitmq-dev
libssh-dev
sqlite3
libsqlite3-dev
&& docker-php-ext-install
bcmath
sockets
pdo pdo_mysql pdo_sqlite
&& pecl install amqp
&& docker-php-ext-enable amqp
# Installing Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer --version
RUN apt-get -y install cron default-mysql-client
WORKDIR /app
# Copy application files into the container
COPY . /app
# Expose port 9000 for the PHP-FPM server
EXPOSE 9000
# The startup command to run PHP-FPM
CMD ["php-fpm"]
Also, I found out that – PHP-FPM doesn’t handle HTTP requests directly; it needs a web server like Nginx or Apache to translate HTTP requests into FastCGI requests that PHP-FPM can handle.
So I guess need image which I can access with HTTP request?
Also my docker-compose.yaml file
version: '3.8'
services:
nginx:
image: nginx:latest
ports:
- "80:80"
volumes:
- "./docker-configs/nginx.conf:/etc/nginx/conf.d/default.conf"
- ".:/app:cached"
php:
build:
context: ./docker-configs/php
volumes:
- "./docker-configs/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
- ".:/app:cached"
environment:
PHP_IDE_CONFIG: "serverName=Docker"
database:
image: nouchka/sqlite3:latest
stdin_open: true
tty: true
volumes:
- ./sqlite-data:/var/lib/sqlite
Can someone please help? Thanks




