Error updating Docker PHP version for WP-CLI

Hello Gareth :wave:

Thank you for reporting it here.
As I could see from the report/error, it seems due to the “User Permission” issue as per that message:

update-alternatives: error: error creating symbolic link '/etc/alternatives/php.dpkg-tmp': Permission denied

I noticed that you ran that update-alternatives --config php command line with the user:
www-data

I suspect you might be connecting to the local containr/Docker with this command perhaps?

docker exec -it devkinsta_fpm sudo -H -u www-data bash

If that so, please try the following steps instead:

  1. Connect to the local FPM container with:
    docker exec -it devkinsta_fpm bash
    (so it will be using the default root user instead of www-data user)

  2. In the FPM container, type:
    update-alternatives --config php

  3. Select the PHP version from the list (and enter), and done.
    The PHP version should be changed properly now.

Please give it a try and let me know if it works for you.

Cheers,
Agus