installing wordpress with wp-cli from docker compose - wordpress

I'm attempting to launch WordPress and set up WP-CLI with several options from docker, however, I am encountering difficulties in correctly configuring the Docker file.
the error:
The container name "/wordpress" is already in use by container "47a9242ec052b7a1196540ded8f1dce39ca97efb8e6def7cf5f9480221db991e". You have to remove (or rename) that container to be able to reuse that name.
My docker-compose file
services:
database:
image: ${DATABASE}:${DATABASE_VERSION}
platform: linux/x86_64
volumes:
- db_data:/var/lib/mysql
container_name: ${COMPOSE_PROJECT_NAME:-database}
restart: always
env_file: .env
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
networks:
- wordpress-network
phpmyadmin:
depends_on:
- database
image: phpmyadmin/phpmyadmin:latest
container_name: ${COMPOSE_PROJECT_NAME:-phpmyadmin}
restart: always
env_file: .env
environment:
PMA_HOST: ${PMA_HOST}
PMA_USER: ${PMA_USER}
PMA_PASSWORD: ${PMA_PASSWORD}
ports:
- ${PHPMYADMIN_PORT}
networks:
- wordpress-network
wordpress:
depends_on:
- database
image: wordpress:latest
container_name: ${COMPOSE_PROJECT_NAME:-wordpress}
restart: always
ports:
- ${PORTS}
env_file: .env
environment:
WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
WORDPRESS_TABLE_PREFIX: ${WORDPRESS_TABLE_PREFIX}
WORDPRESS_DEBUG: 1
volumes:
- wp_data:/var/www/html:rw
- ./configuration/apache2.conf:/etc/apache2/apache2.conf:ro
networks:
- wordpress-network
wp-cli:
depends_on:
- database
- wordpress
image: wordpress:cli
container_name: ${COMPOSE_PROJECT_NAME:-wordpress-cli}
env_file: .env
# This is required to run wp-cli with the same
# user-id as wordpress. This way there are no permission problems
# when running the cli
user: xfs
environment:
WP_CLI_CACHE_DIR: ${WP_CLI_CACHE_DIR}
WORDPRESS_DB_USER: ${MYSQL_USER}
WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- wp_data:/var/www/html:rw
- ./bin/install-wp.sh:/usr/local/bin/install-wp:ro
networks:
- wordpress-network
volumes:
db_data:
wp_data:
networks:
wordpress-network:
driver: bridge

Related

Add ioncube to wordpress image

I'm trying to serve multiple instances of
i have the following docker compose script to create a docker-WordPress container :
version: '3.7'
services:
db:
container_name: "${SITE_NAME}-db"
image: mysql:latest
env_file:
- .env
environment:
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_RANDOM_ROOT_PASSWORD: ${ROOT_PASSWORD}
ports:
- "3306"
volumes:
- './db:/var/lib/mysql'
restart: always
networks:
- lan
site:
container_name: "${SITE_NAME}-web"
image: wordpress:latest
environment:
WORDPRESS_DEBUG: 0
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: ${DB_USER}
WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
WORDPRESS_DB_NAME: ${DB_NAME}
WORDPRESS_CONFIG_EXTRA: |
define('AUTOMATIC_UPDATER_DISABLED', true);
VIRTUAL_HOST: ${SITE_DOMAIN},www.${SITE_DOMAIN}
LETSENCRYPT_HOST: ${SITE_DOMAIN},www.${SITE_DOMAIN}
volumes:
- './wordpress:/var/www/html/wp-content'
- './upload.ini:/usr/local/etc/php/conf.d/uploads.ini'
restart: always
depends_on:
- db
networks:
- lan
- net
volumes:
db:
wordpress:
upload.ini:
networks:
lan:
internal: true
net:
external: true
On instance of a website requires for one of it's plugins the installation of ioncube
I cant seem to make it work.
Is there a way to add ioncube ?
Perhaps it makes sense to Use a custom Docker Image for your Wordpress instance. You can create one based on the wordpress image you already use and than add ioncube to it for example like this:
https://github.com/atsu666/docker-ioncube/blob/master/Dockerfile#L43

im tring to install the wordpress on the docker-compose.yml but not working

This is the code I have tried but not working. is there any better code available there installation of the Wordpress in the docker-compose?
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
Services:
web:
image: wordpress
ports:
- 80:80
environment:
WORDPRESS_DB_HOST: "db"
WORDPRESS_DB_USER: "root"
WORDPRESS DB PASSWORD: "Password"
WORDPRESS DB NAME: "wordpress"
db:
image: mysql
expose:
-3306
environment:
MYSQL ROOT PASSWORD: "Password"
MYSQL DATABASE: "wordpress"

Docker wordpress behind proxy generates 503

I tried to setup docker with multiple wordpress-sites behind a nginx-proxy. So I tried various instructions, but none worked.
This is one of them:
version: '3'
services:
nginx-web:
image: nginx
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
container_name: nginx-web
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./data/nginx/conf.d:/etc/nginx/conf.d
- ./data/nginx/vhost.d:/etc/nginx/vhost.d
- ./data/nginx/html:/usr/share/nginx/html
- ./data/nginx/certs:/etc/nginx/certs:ro
- ./data/nginx/htpasswd:/etc/nginx/htpasswd:ro
depends_on:
- new-site-wordpress
nginx-gen:
image: jwilder/docker-gen
command: -notify-sighup nginx-web -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
container_name: nginx-gen
restart: always
volumes:
- ./data/nginx/conf.d:/etc/nginx/conf.d
- ./data/nginx/vhost.d:/etc/nginx/vhost.d
- ./data/nginx/html:/usr/share/nginx/html
- ./data/nginx/certs:/etc/nginx/certs:ro
- ./data/nginx/htpasswd:/etc/nginx/htpasswd:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./data/nginx.tmpl:/etc/docker-gen/templates:ro
nginx-letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-letsencrypt
restart: always
volumes:
- ./data/nginx/conf.d:/etc/nginx/conf.d
- ./data/nginx/vhost.d:/etc/nginx/vhost.d
- ./data/nginx/html:/usr/share/nginx/html
- ./data/nginx/certs:/etc/nginx/certs:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
NGINX_DOCKER_GEN_CONTAINER: nginx-gen
NGINX_PROXY_CONTAINER: nginx-web
new-site-db:
container_name: demo-db
image: mariadb:latest
restart: unless-stopped
volumes:
- ./data/db/demo:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: demo_wordpress
MYSQL_USER: wordpress_user
MYSQL_PASSWORD: wordpress_password
new-site-wordpress:
depends_on:
- new-site-db
container_name: demo-wp
image: wordpress:latest
restart: unless-stopped
volumes:
- ./data/wp/demo:/var/www/html
- ./conf.d/php.ini:/usr/local/etc/php/conf.d/php.ini
environment:
WORDPRESS_DB_HOST: demo-db:3306
WORDPRESS_DB_NAME: demo_wordpress
WORDPRESS_DB_USER: wordpress_user
WORDPRESS_DB_PASSWORD: wordpress_password
WORDPRESS_TABLE_PREFIX: wp_
VIRTUAL_HOST: demo.servles.de
LETSENCRYPT_HOST: demo.servles.de
LETSENCRYPT_EMAIL: louis#servles.de
wpcli:
image: tatemz/wp-cli
volumes:
- ./data/wp/demo:/var/www/html
depends_on:
- new-site-db
entrypoint: wp
networks:
default:
external:
name: test-network
All containers are created and work.
A wget to the IP of the demo-wp-container brings the correct index file.
But when the domain is called, only "503 Service Temporarily Unavailable
nginx/1.19.1"
What am I doing wrong? Or does someone have a working Compose-file?
Look forward to the support.

Create a Wordpress Docker image with plugins

Sir,
I have got my wordpress and some wordpress plugins installed. How can I create a docker-compose.yaml so that my plugin folder contains php files inside instead of empty folders ?
Here is my docker-compose.yaml given from others, there has no custom plugins installed :
version: '3'
services:
# Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wpsite
# phpmyadmin
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
networks:
- wpsite
# Wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- '8800:80'
restart: always
volumes: ['./:/var/www/html' , './:/var/www/html/wp-content/plugins/acf-to-rest-api' ]
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- wpsite
networks:
wpsite:
volumes:
db_data:

Increased Docker memory size and now docker compose wont work

I increased my docker for windows CPU and memory size in settings, and it did a restart, then I tried to run docker-compose up -d on my project and I got the following error ERROR: Named volume "C:/Users/andersk/sites/sylr:/var/www/html" is used in service "wordpress" but no declaration was found in the volumes section.
Here is my docker compose file, it was working just fine up until I increased those settings in the docker.
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "2000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- C:/Users/andersk/sites/sylr:/var/www/html
volumes:
db_data: {}
If ran from WSL one can change your docker-compose.yml to the following
version: '3.3'
services:
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "2000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- /mnt/c/Users/andersk/sites/sylr:/var/www/html
Note the prefix /mnt/c instead of C:/
Another method would be to use a relative path or create a named volume like:
version: '3.3'
services:
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "2000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- some_volume_name:/var/www/html
volumes:
some_volume_name: {}
If ran from Powershell it should work just out of the box.
You can use docker named volume in place and share that name across multiple containers, it would also make debugging easier
version: "3"
services:
db:
image: db
volumes:
- data-volume:/var/lib/db
backup:
image: backup-service
volumes:
- data-volume:/var/lib/backup/data
volumes:
data-volume:

Resources