Wordpress: How to set a multisite workspace? Or change wp-config.php

Created on 20 Dec 2018  路  6Comments  路  Source: docker-library/wordpress

When I define a volume for my theme then I cant mount the wp-config.php file. Is it possible to change the wp-config.php on docker-compose up command?

```version: '3.3'

services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
MYSQL_USER: root
MYSQL_PASSWORD: root

wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: root
volumes:
- ./test-theme:/var/www/html/wp-content/themes/test-theme
- ./test:/var/www/html/test
volumes:
db_data: {}```

question

Most helpful comment

Using this docker-compose.yml it works

version: '3'
services:
   db:
     image: mysql:5.7
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: root
       MYSQL_DATABASE: wordpress
       MYSQL_USER: root
       MYSQL_PASSWORD: root

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: root
       WORDPRESS_DB_PASSWORD: root
       WORDPRESS_CONFIG_EXTRA: define('WP_ALLOW_MULTISITE', true );
$ docker exec -it wordpress-360_wordpress_1 bash

root@c05456cc0af8:/var/www/html# grep -i multisite wp-config.php 
define('WP_ALLOW_MULTISITE', true );

All 6 comments

The wp-config.php is auto-generated from your environment variables, so you can configure it further by using the env vars or not use any and mount your wp-config.php without it being generated.

Thanks.

Am I doing something wrong?

The wp-config is not having any of my "WORDPRESS_CONFIG_EXTRA"

Already removed the container and reinstalled it with this docker.compose.yml file.

yaml web: image: wordpress volumes: - ./vpltorg:/var/www/html/wp-content/themes/vpltorg - ./plugins:/var/www/html/wp-content/plugins - ./uploads:/var/www/html/wp-content/uploads - ./mitglieder:/var/www/html/mitglieder links: - mysql environment: - WORDPRESS_DB_PASSWORD=root ports: - "8080:80" mysql: image: mysql:5.6 environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_DATABASE=vplt - WORDPRESS_CONFIG_EXTRA= define('WP_ALLOW_MULTISITE', true ); ports: - 3306:3306

Using this docker-compose.yml it works

version: '3'
services:
   db:
     image: mysql:5.7
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: root
       MYSQL_DATABASE: wordpress
       MYSQL_USER: root
       MYSQL_PASSWORD: root

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: root
       WORDPRESS_DB_PASSWORD: root
       WORDPRESS_CONFIG_EXTRA: define('WP_ALLOW_MULTISITE', true );
$ docker exec -it wordpress-360_wordpress_1 bash

root@c05456cc0af8:/var/www/html# grep -i multisite wp-config.php 
define('WP_ALLOW_MULTISITE', true );

Indeed, as demonstrated, WORDPRESS_CONFIG_EXTRA needs to be set on the wordpress container during the first startup, and if it is embedded in YAML it needs to be using the appropriate YAML syntax for it to actually work.

@wglambert thank you very much.
This worked and the wp-config.php changed.

Unfortunatly I get the message that wordpress can`t make a multisite network on the port like 8000. Do you guys know a workaround for this?
Do I have to define a local domain?

Just for the record: it works on the port 80
So the line should be
ports:
- "80:80"

Was this page helpful?
0 / 5 - 0 ratings