In that local docker container , could you please run this command (run as root ): update-alternatives --config php
it would show you to change the PHP version (7.4) to 8.1 for example, something like this:
once changed to PHP 8.1 , you may want to try to run the WP CLI again with your WP site which requires PHP 8.1 and see if that would work properly as expected?
When I tried that before I got a permission denied error and when I tried with sudo I didn’t know the password. Then when you said (run as root) it occurred to me, I have been going into the container as www-data so that when I created files they would be owned by the web server. I went in again as root and it worked. Thanks!