7.1-fpm
,latest
(7.1/Dockerfile)
Based on the Official PHP Docker image and Offical Nginx Docker image. This image adds some extensions that are necessary in most common use cases for running PHP projects.
Nginx and PHP-FPM services running together in the one container. The webserver solution for dockerized PHP application. You should always use nginx-proxy in front of this container to manage load balancing, server names and SSL traffic (e.g let's encrypt).
This image actually only helps to run you application on port 80
. It simulates nodejs app server or golang web server.
It's based on socifi/php and official nginx images.
-
Create own
Dockerfile
(see Examples) -
Customise
default
vhost file (see Examples) PHP-FPM service is listening onlocalhost:9000
by default -
Add your code into
/app
folder -
Build image (e.g.:)
docker build -t namespace/application:latest .
-
Run the image (e.g.:)
docker run -it --rm -p 80:80 namespace/application:latest
project Dockerfile
placed in the project root.
FROM socifi/nginx-php:7.1-fpm
LABEL maintainer "your name"
ADD etc/nginx/default /etc/nginx/sites-enabled/default
WORKDIR /app
COPY . /app
VOLUME /app
Example of default vhost configuration file placed in the ./etc/nginx/default
# copy this file into socifi/nginx-php:7.1-fpm as /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /app;
index index.php;
error_log /dev/stdout info;
access_log /dev/stdout;
server_name localhost;
location / {
try_files $uri $uri/ /index.html;
}
location ~ \.php[t]?$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass localhost:9000;
include /etc/nginx/fastcgi_params;
}
}