Skip to content

docker wp-config.php & database connection  #5513

@Kipjr

Description

@Kipjr

Hi,

I've got a running WP-container with the following wp-config.php (official source):

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress') );

/** MySQL database username */
define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );

/** MySQL database password */
define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );

Then I want to execute a basic command but that fails due to the parsing of the database credentials

docker run -it --rm \
    --volumes-from wp \
    --network container:wp  \
     wordpress:cli-php8.0 user list

Error: Error establishing a database connection.

Is there any way how I can supply the credentials?

I can already extract them from docker-compose.yml using this:
db_name=$(grep -Po '(?<=WORDPRESS_DB_NAME: )(.*)' docker-compose.yml)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions