Home

Building a PHP App with Docker

By Joel Dare - Written March 25, 2023

The following is a quick start for running a simple PHP application via Docker. Replace $NAME with a name you want to use for your container.

Dockerfile

# Use the alpine base image (small)
FROM php:apache

# Copy the files into place
COPY ./ /var/www/html/

# Ports we want in the container
EXPOSE 80

Building the Image

docker build --no-cache --tag $NAME .

Running a Container

docker run \
    --hostname $NAME \
    --publish "8080:80" \
    --name $NAME \
    $NAME

Build your next site in pure HTML and CSS

Want to build your next site in pure HTML and CSS? Join the free Five-Day Neat Starter Email Course and build a lean, production-ready page before Friday.

Email Me the Crash Course


JoelDare.com © Dare Companies Dotcom LLC

Terms - Privacy