a bunch of purple flowers with water droplets on them

Understanding PHP Version Availability in Ubuntu Containers


When working with Docker containers based on Ubuntu, one might encounter limitations regarding the availability of PHP versions. This blog post explores these limitations, specifically between Ubuntu 18.04 and Ubuntu 20.04 containers, and provides insights into how you can successfully manage PHP installations within these environments.


PHP is a widely-used open-source general-purpose scripting language that is especially suited for web development. The availability of different PHP versions in Docker containers can significantly affect your development and deployment processes. Recently, I encountered a situation that necessitated a deeper dive into which PHP versions are installable on different Ubuntu containers.

The Discovery Process

Initially, I attempted to install PHP versions 7.3 and above in a Docker container based on ubuntu:18.04. Despite my efforts and even after adding the popular Ondřej Surý PPA, I was unable to install PHP versions higher than 7.2. This limitation posed a significant challenge, as many of my projects required at least PHP 7.3 due to various dependencies and features introduced in later PHP versions.

Experimenting with Ubuntu 18.04

Using the ubuntu:18.04 container, I attempted to install PHP 7.3 and 8.0 by leveraging the following commands:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.3

However, I encountered the following issue:

E: Unable to locate package php7.3
E: Couldn't find any package by glob 'php7.3'
E: Couldn't find any package by regex 'php7.3'

Switching to Ubuntu 20.04

Prompted by the challenges faced with ubuntu:18.04, I decided to switch my Docker container to ubuntu:20.04. After applying the same steps, I was pleasantly surprised to find that I could successfully install PHP versions 7.3, 7.4, and even PHP 8.0 without any issues.


This experience highlighted a crucial aspect of working with Docker and Ubuntu containers – the base image significantly impacts the availability of software packages. Ubuntu 18.04, being an older LTS release, does not natively support PHP versions higher than 7.2 without additional, sometimes complex, configurations. In contrast, Ubuntu 20.04, a more recent LTS version, has out-of-the-box support for newer PHP versions, reflecting the advancements in software compatibility and availability.


For developers and DevOps engineers working with PHP in Docker environments, understanding the relationship between the base container image and software package availability is crucial. If you’re planning to use PHP versions 7.3 or newer, opting for an ubuntu:20.04 container would be the more straightforward and efficient choice.

This exploration not only solved my immediate problem but also served as a valuable reminder of the importance of keeping both software and knowledge up to date. I hope sharing this experience helps others navigate similar challenges in their development workflows.


  • Always check the PHP version compatibility with your chosen Ubuntu container version before starting your project setup.
  • Consider upgrading your Docker container to a newer Ubuntu version if you require support for newer PHP versions.
  • Stay informed about the PHP versions supported by Ubuntu releases to ensure smooth development and deployment processes.