There is already an official PHP Docker image, but it is Debian Based.
I mostly use Archlinux and this is how I build mine
Base install
FROM archlinux:latest RUN pacman -Sy \ --noconfirm \ php \ php-apache php-pgsql \ apache \ mariadb-clients wget
Composer install
RUN wget https://getcomposer.org/download/latest-stable/composer.phar -O /composer/bin/composer RUN chmod 755 /composer/bin/composer
Symfony CLI install, when needed
RUN wget https://github.com/symfony/cli/releases/download/v4.25.2/symfony_linux_amd64.gz && gunzip symfony_linux_amd64.gz RUN mkdir -pv /symfony/bin && mv symfony_linux_amd64 /symfony/bin/symfony && chmod 755 /symfony/bin/symfony
PATH ajustment
ENV PATH="/composer/bin:/symfony/bin:"${PATH}
I often need to add these lines when Docker building:
RUN composer config extra.symfony.allow-contrib true RUN composer install --no-interaction