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:
Related
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
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
I am using the below codes but docker-compose file not working. I need to setup WordPress in docker for different environment.
ERROR: services.wordpress Additional property port is not allowed
Code:
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
# Wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
port:
- '8000:80'
restart: always
volumes: ['./:/var/www/html']
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- wpsite
networks:
wpsite:
volumes:
db_data:
Actually it's "ports" (plural) that can accept a list, delimited by "-" and not 'port' (singular). Kindly check the below docs for docker compose file (yaml)
https://docs.docker.com/compose/compose-file/compose-file-v3/
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"
i have created one wordpress site using docker. to open it i need to open browser in got to localhost:8000. But if i want to make multiple wordpress sites how and where and what i need to configure to reach every each of them seperatly, becouse i cant get to them using only the same link. i am noob at docker.
i have created .yaml file from tutorial in youtube
version: '3'
# Database
services:
db:
image: mysql:5.7
platform: linux/amd64
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:
- '8000:80'
restart: always
volumes: ['./:/var/www/html']
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- wpsite
networks:
wpsite:
volumes:
db_data:
and then i run the dockeer command
docker-compose up -d
which made all wordpress files
to open it i need to open link localhost:8000
how do i open another wordpress site? becouse i cant open them both with the same link.
If you want to be able to access multiple services then just assign them different ports.
In your example you configured wordpress to be exposed on port 8000 using:
ports:
- '8000:80'
So just assign to another wordpress instance(s) different port(s) (eg 8001, 8002, ...) using:
ports:
- '8001:80'
Example docker-compose.yaml
version: '3'
services:
db:
image: mysql:5.7
platform: linux/amd64
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress-site1
MYSQL_USER: wordpress-site1
MYSQL_PASSWORD: wordpress-site1
networks:
- wpsite
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
networks:
- wpsite
wordpress-site1: # Wordpress site 1
depends_on:
- db
image: wordpress:latest
ports:
- '8000:80' # This site will be accessible on localhost:8000
restart: always
volumes: ['./site-1:/var/www/html'] # Set different path on host
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress-site1
WORDPRESS_DB_USER: wordpress-site1
WORDPRESS_DB_PASSWORD: wordpress-site1
networks:
- wpsite
wordpress-site2: # Wordpress site 2
depends_on:
- db
image: wordpress:latest
ports:
- '8001:80' # This site will be accessible on localhost:8001
restart: always
volumes: ['./site-2:/var/www/html'] # Set different path on host
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress-site2
WORDPRESS_DB_USER: wordpress-site2
WORDPRESS_DB_PASSWORD: wordpress-site2
networks:
- wpsite
# Other wordpress instances
networks:
wpsite:
volumes:
db_data:
Don't forget that every wordpress service will need it's own database.
You can either define for each wordpress service it's own database service or use single (shared) DB service and create on it multiple databases (one for each wordpress service).
To do so first start up only db and phpmyadmin services using:
$ docker-compose up -d db phpmyadmin
Since PhpMyAdmin is set to be exposed on port 8080 go to http://localhost:8080, log in and create for each wordpress service it's own database and user.
Once done, update WORDPRESS_DB_* env variables (if needed) in docker-compose.yaml to match databases and user credentials you just created and if everything is ok start all wordpress services.
Based on example docker-compose.yaml you should be able to access:
wordpress-site1 on hppt://localhost:8000
wordpress-site2 on hppt://localhost:8001
...