How to update wp-config file in Docker

This might seem like a dumb question, but I am stuck here for 6 hours rn. and I need a way out. I am too tired to do anything else.

I am trying to change our blogs from WordPress to inside a docker container, so that we can move around it easily. I wrote a docker-compose file for the purpose and it ran smoothly the first time. But I made some mistakes on configs and missed to write the `HOME` and `SITEURL` on the docker-compose file in the beginning. Now, I can’t seem to change the `wp-config.php`. according to WordPress, it can’t be updated from the entrypoint script once it’s already been written. I tried a bunch of other scenarios:

  1. I tried to use `docker exec` command to update the wp-config.php file. bash does not have vim/nano there.

  1. I deleted all the containers and volumes and images, but still, it doesn’t change anything. I downed and re-uploaded the compose file many times, but nothing is changing.

  1. I tried to delete the volume using `docker volume rm` command. but it shows an error, even though I have no container running.

    `Error response from daemon: remove <project_name>_wordpress_data: volume is in use – [43ade39ba3a495154fefd9ccd79b2c2c53765482e2c7c4d2859b7051383839ae]

Here’s a snippet of my compose file. What should I do now? [I need to change the home and siteurl because the WordPress will be served from a different server.]

“`

 version: '3' services: db: image: mysql:8.0 container_name: db restart: unless-stopped env_file: .env environment: - MYSQL_DATABASE=wordpress volumes: - mysql_db_data:/var/lib/mysql command: '--default-authentication-plugin=mysql_native_password' networks: - app-network wordpress: depends_on: - db image: wordpress:5.1.1-fpm-alpine container_name: wordpress restart: unless-stopped env_file: .env environment: - WORDPRESS_DB_HOST=db:3306 - WORDPRESS_DB_USER=$MYSQL_USER - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD - WORDPRESS_DB_NAME=wordpress - WORDPRESS_CONFIG_EXTRA= define('WP_HOME','http://dev.insurance.kothay.com/'); define('WP_SITEURL','http://dev.insurance.kothay.com/'); volumes: - wordpress_data:/var/www/html networks: - app-network webserver: depends_on: - wordpress image: nginx:1.15.12-alpine container_name: webserver restart: unless-stopped ports: - "8080:80" volumes: - wordpress_data:/var/www/html - ./nginx-conf:/etc/nginx/conf.d networks: - app-network volumes: wordpress_data: mysql_db_data: networks: app-network: driver: bridge 

Docker message:

“`

wordpress | WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists wordpress | The contents of this variable will _not_ be inserted into the existing "wp-config.php" file. wordpress | (see https://github.com/docker-library/wordpress/issues/333 for more details) w ``` 

Let me know what I can do. Thanks in advance.

submitted by /u/im_matur3
[link] [comments]