Reputation: 15
I want to setup a wordpress container,install wordpress with default servername, username and password. Later I want to use wordpress:cli to change the default language, add some plugins, etc.
The goal is to test a Wordpress plugin in different scenarioes.
But I'm stuck with the basic setup:
version: "3.8"
services:
# WordPress Service
wordpress:
image: wordpress:latest
ports:
- "8088:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
- wordpress_data:/var/www/html
depends_on:
db:
condition: service_healthy
# MySQL Service
db:
image: mysql:8.0
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
#WP-CLI Service
wp-cli:
image: wordpress:cli
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
- wordpress_data:/var/www/html
depends_on:
- wordpress
entrypoint: wp
command: >
sh -c '
wp core install --url="http://localhost:8088" --title="Example Site" --admin_user="admin" --admin_password="admin_password" --admin_email="[email protected]" --skip-email;
'
volumes:
wordpress_data:
db_data:
I expected to end up with a finished installed wp.
I'm getting this error:
wp-cli-1 | Error: The site you have requested is not installed. wp-cli-1 | Run
wp core install to create database tables. wp-cli-1 exited with code 1
my http://localhost:8000/wp-admin/install.php is up and running and I can successfully install everything manually.
I think this might have to do with the wp-config.php
/** Database username */ define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );
/** Database password */ define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );
but I don't understand how to fix it
Upvotes: 1
Views: 666
Reputation: 85
It looks like the only thing preventing your setup from running is this line
entrypoint: wp
in wp-cli
service configuration. Just remove it.
In logs you'll get info about successfull install but also a new warning:
Unable to create directory wp-content/uploads/2024/02.
Is its parent directory writable by the server?
Success: WordPress installed successfully.
It's about write permissions. To fix the warning add this line to wp-cli
service:
user: xfs
I also remember that later during some wp-cli
operations I had issuses with wp-cli
not being able to create some cache directory. Adding single environment variable solved this.
environment:
WP_CLI_CACHE_DIR: /var/www/html/.wp-cli/cache/
Upvotes: 0