Joel Dare

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.