How to change wordpress table prefix in Docker image?

Dear experts,

We are trying to use Docker official image to deploy WordPress sites. It seems working fine after configuring. However, I found that the default table prefix is wp_ while we need to change it to something else. I’ve been googling around with no luck, even using WordPress plugin which seemed to change it. However after change was made, the image was somehow starting over but asking to install a new WordPress site.

Any idea how we can change the table prefix and get to install our new WordPress by using custom table prefix? Thanks a lot in advance.

P.S. We are using Docker for Windows

Hi

Its always an good idea to check the docker hub page for that image:

-e WORDPRESS_TABLE_PREFIX=...

https://hub.docker.com/_/wordpress

Dear @terpz,
Thanks a lot for your comment. I’m very new to docker so please bear my further questions.
So we need to modify our wp-config-docker.php file first, then we run the docker image with this additional parameter, am I right?

Hi again.

I think the easiet is to just start over with that parameter in the docker run/compose.

But, if you need to keep the existing installation, then I THINK you just need to:

  1. stop the WP container
  2. make the changes in the database
  3. add the WORDPRESS_TABLE_PREFIX env variable ( i belive it will rewrite the wp-config-docker.php, but you can edit it yourself )
  4. start the WP container again

Dear @terpz,

Thanks again. I might need to spend some time to learn how to perform the step 2 and 3:)
Thanks again!

Yea thats why i said i think its easier just to start over :wink:

The wp-config-docker needs to be modified. Php file before running the Docker image with this additional parameter, am I right?

  1. WP should be stopped.
  2. Update the database.
  3. Set WORDPRESS_TABLE_PREFIX in the environment variables (I believe it will overwrite wp-config-docker)…
  4. Restart the WordPress container.

With installation of docker easiest way run file open PHP file directory and open images with its right parameter or past extra code in file.
secondly change database with addition WORDPRESS_TABLE_PREFIX as a variable.