Docker PHP built-in server web app container and Nginx-proxy

I have been migrating some projects to my Digital Ocean server with Docker installed. One of these migration projects uses PHP in its back-end and had Lighttpd serving the content. Recently I've ventured into the NodeJS world, but I started that PHP project before. Now I use Express for serving my Javascript apps. So I wanted to find an minimalistic replacement for Lighttpd to bundle with my PHP app container.

PHP built-in server

PHP has an built-in http server. Usage is very simple, from your app root run: php -S localhost:8080
This suits my needs perfectly. Notice that the PHP manual warns that the server shouldn't be used on a public network, only for development. I like gray lines.


FROM php:7.1-cli

COPY . /usr/src/app
WORKDIR /usr/src/app


CMD php -S


I run the container like this: docker run -d -e --name app_name image_name

The -e environmental variable is for my Nginx-proxy container that handles incoming requests and points them to the correct content. This way I can host multiple domains with one ip on DigitalOcean.

Find out more about Nginx-proxy: