Repo used from my talk: How to put your Docker image on a diet
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

How To Put Your Docker Image On A Diet

A talk by Peter Fisher

The application is a very simple Symfony 3.3.* web app.

Each tag demonstrates how to reduce the file size of the Docker image which is being built.

The images are also available on the Docker Hub

The talk was first given at PHP South West

This is tag 0.6.0

Docker image file size: 252MB


You will need:

  • git
  • composer
  • Docker


Clone the repo

$ git clone


Update the website using composer

$ composer install -n -d site


Create a Docker machine (Optional)

$ docker-machine create how-to-put-your-docker-image-on-a-diet
$ docker-machine env how-to-put-your-docker-image-on-a-diet
$ eval $(docker-machine env how-to-put-your-docker-image-on-a-diet)

Build 0.6.x of the application

$ docker build -t howtocodewell/how-to-put-your-docker-image-on-a-diet:0.6.0 .


Pull the image from the Docker hub

$ docker pull howtocodewell/how-to-put-your-docker-image-on-a-diet:0.6.0

Run 0.6.x of the application

$ docker run --name apache2 -d -p 80:80 howtocodewell/how-to-put-your-docker-image-on-a-diet:0.6.0

Check the IP address of the Docker machine

$ docker-machine ip how-to-put-your-docker-image-on-a-diet

Enter the IP address into the browser. The application should be running


The easiest way to remove everything is to remove the Docker machine

$ docker-machine rm how-to-put-your-docker-image-on-a-diet

Or remove just the container

$ docker rm -f apache2

Or remove the image

$ docker rmi -f howtocodewell/how-to-put-your-docker-image-on-a-diet:0.6.0