How setup wp-cli (installed with dnf ) and run the command `wp shell` with an existed wordpress container

Helo pals. after create an wordpres container environment now want to use wp cli the command wp shell to check some wordpress functions, but have problems about database connections.
Wordpress and mariadb are containers inside a pod created using podman, both have a host volume mounted there.

I have installed first an neccesary package.

sudo dnf install wp-cli
sudo dnf install php-mysqlnd
❯ wp shell 
Error: Error establishing a database connection.

How can we setup wp cli to use the mariadb container without break something else.

❯ wp --info
OS:	Linux 5.19.11-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 23 15:07:44 UTC 2022 x86_64
Shell:	/bin/bash
PHP binary:	/usr/bin/php
PHP version:	8.1.10
php.ini used:	/etc/php.ini
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/home/chris/Documents/podman-practice/quickly-wp-httpd/var-www-html
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.4.0

I had installed wp-cli by dnf the package manager of my fedora workstation 36(Linux System) and was trying running the command wp shell in the root of my wordpress web without any success.
The solution was edit the wp-config.php file using the environment variables data used when you created the database container. Edit the second parameter of the function getenv_docker('CONTAINER_VARIABLE', 'edit_here') to match your environment variables values.
Example in my case.

define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'ecommerce') );
define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'chris') );
define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'maGazine1!') );
define( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST', '127.0.0.1:3306') );

Then inside my root directory which is var-www-html can run the command wp shell

❯ wp shell 
wp> 

Now can check wordpress functions, e.g

❯ wp shell      
wp> get_template_directory_uri()
=> string(56) "http://localhost:8080/wp-content/themes/construction-hub"
wp> 

Cool.

Something that is strange is that wp-cli don’t detect the project configuration. Thanks in advance about that, so far it doesn’t affect my work.

❯ wp --info
OS:	Linux 5.19.11-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 23 15:07:44 UTC 2022 x86_64
Shell:	/bin/bash
PHP binary:	/usr/bin/php
PHP version:	8.1.10
php.ini used:	/etc/php.ini
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/home/chris/Documents/podman-practice/quickly-wp-httpd/var-www-html
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.4.0