Home - Zines

Building a PHP App with Docker

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

Written by Joel Dare on March 25th 2023.


Get battle-tested dev tips, terminal wizardry, and practical Mac hacks from a veteran engineer who speaks your language. Subscribe now and power up your toolkit—no fluff, just real code magic.

Show Me Your Hacks

JoelDare.com © Dare Companies Dotcom LLC

Terms - Privacy