Search code examples
wordpressdockerdockerfilephp-8

How to update WordPress dockerfile to use PHP 8?


I am using a docker image to build a WordPress site on Amazon Web Services, and it is currently using WordPress 6.0 but PHP 7.4. I want to update the image so it uses PHP 8.

This is part of the Dockerfile currently -

FROM wordpress:6.0
ARG ENV=production

RUN apt-get update && apt-get install -y \
  bash \
    curl \
    python \
    unzip \
  webpack \
  git \
    && cd /tmp \
  && curl "https://s3.amazonaws.com/aws-cli/awscli-bundle-1.16.188.zip" -o "awscli-bundle.zip" \
  && unzip awscli-bundle.zip \
  && ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws \
  && rm awscli-bundle.zip \
  && rm -rf awscli-bundle \
  && rm -rf /tmp/src \
  && rm -rf /var/cache/apk/*

I've tried changing it to -

FROM wordpress:6.0
FROM php:8.0-apache
ARG ENV=production

as well as

FROM wordpress:6.0:php:8.0-apache
ARG ENV=production

but I get an error when trying to build


Solution

  • This:

    FROM wordpress:6.0
    FROM php:8.0-apache
    

    Is telling Docker to build your image from two different base images, which makes no sense.

    This:

    FROM wordpress:6.0:php:8.0-apache
    

    You are just making up some new Docker image tag syntax, which is not going to work.

    You need to look at what base WordPress docker images are available, and pick one of those available images. For example wordpress:6.0-php8.0. You would change your Dockerfile to:

    FROM wordpress:6.0-php8.0