Here you go: https://hub.docker.com/r/existenz/webstack
This is a container of a colleague of mine. We run this on production and it works perfectly fine ;)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to deploy my nginx + php-fpm in one image. Is there anyone done this before?
Here you go: https://hub.docker.com/r/existenz/webstack
This is a container of a colleague of mine. We run this on production and it works perfectly fine ;)
That's a great image except I can't do pecl install or call php command.
That's not what you asked, right?
Anyway, it's just an Alpine container with the most common stuff installed. You can extend it with extra dependencies if you want
// Dockerfile
FROM existenz/webstack:7.3
EXPOSE 80
EXPOSE 443
RUN apk -U --no-cache add \
php7 \
php7-ctype \
php7-curl \
php7-dom \
php7-iconv \
php7-intl \
php7-json \
php7-mbstring \
php7-pdo_mysql \
php7-ssh2 \
npm
COPY --chown=php:nginx . /www
RUN find /www -type d -exec chmod -R 555 {} \; \
&& find /www -type f -exec chmod -R 444 {} \; \
&& find /www/storage /www/bootstrap/cache -type d -exec chmod -R 755 {} \; \
&& find /www/storage /www/bootstrap/cache -type f -exec chmod -R 644 {} \;
RUN apk -U --no-cache add \
php7-xdebug \
openssh-client
If you want to run php commands you need to build the container and SSH into the container. Assuming you called your container app in your docker-compose.yml file
docker-compose exec app /bin/sh
I've done it once for local development. See below. You might need to tweak it a little bit.
Dockerfile
FROM ubuntu:18.04
LABEL maintainer="Mayur Shingrakhiya <[email protected]>"
ENV DEBIAN_FRONTEND=noninteractive
# RUN apt-get update \
# && apt-get install -y gnupg tzdata \
# && echo "UTC" ? "/etc/timezone" \
# && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get update \
&& apt-get install -y curl zip unzip git supervisor \
nginx php7.2-fpm php7.2-cli php7.2-curl \
php7.2-mysql php7.2-mbstring php7.2-xml \
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& mkdir /run/php \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
ADD nginx.conf /etc/nginx/sites-available/default.conf
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ADD initial.sh /usr/bin/initial
RUN chmod +x /usr/bin/initial
ENTRYPOINT [ "initial" ]
nginx.conf
server {
listen 80 default_server;
root /var/www/html/public;
index index.html index.htm index.php;
server_name localhost;
charset utf-8;
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
error_page 404 /index.php;
}
supervisord.conf
[supervisord]
nodaemon=true
[program:nginx]
command=nginx
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:php-fpm]
command=php-fpm7.2
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
initial.sh
#!/usr/bin/env bash
##
# Ensure /.composer exists and is writable
#
if [ ! -d /.composer ]; then
mkdir /.composer
fi
chmod -R ugo+rw /.composer
##
# Run a command or start supervisord
#
if [ $# -gt 0 ];then
# If we passed a command, run it
exec "$@"
else
# Otherwise start supervisord
/usr/bin/supervisord
fi
Yeah, I just want to a pre-setup phpfpm + Nginx so I can extend to install Redis. Basically, I need the Laravel server in one docker image so I can easily set up another Nginx reverse proxy in my docker-compose.
The above dockerfile is great but isn't it redundant to reinstall the php again?
@mkshingrakhiya May I know the image size?
Dude. It has been over a year so I could not help you with the size. I don't use this setup anymore. Where do you see the redundancy in PHP installation? However, you could fetch PHP image and then on top of that install other services like Nginx and so on like @bobbybouwmann suggested.
I tried to install Nginx on the php-fpm image too but there're some problems with that. I'll try using alpine to follow your setup above.
Post here if you get any problems.
@gthell The Image I provided is a lot smaller because it uses Alpine instead of Ubuntu
@gthell If you're facing issue regarding daemon:
By default, FPM will run in the background so you might need to bring it to the foreground by setting daemonize = no to the default configuration.
Thank you guys I use richarvey/nginx-php-fpm as this image provide everything and I only need to do pecl install require redis extension and copy my laravel folder in. Cheers!
I had to choose best answer though!
@bobbybouwmann Thank you! This is exactly what im looking for cause azure app service requires a single container to be deployed (there's docker-compose support but it's still in preview)
One question remains, how do you run queue:work with this single container? Looking for advice here.
Please or to participate in this conversation.