Is there a way to do this without having to go into the container and install it? Seems kind of weird they wouldn't include this with the Wordpress image. Anyway - Heres what I have at the moment.
How would you do this?
version: '3.3'
services:
db:
image: mysql
restart: always
volumes:
- mysql_data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=admin
- MYSQL_DATABASE=admin
- MYSQL_USER=admin
- MYSQL_PASSWORD=admin
wordpress:
image: wordpress
depends_on:
- db
ports:
- '1234:80'
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content
environment:
- WORDPRESS_DB_HOST=db:3306
- WORDPRESS_DB_USER=admin
- WORDPRESS_DB_PASSWORD=admin
- WORDPRESS_DB_NAME=admin
- WORDPRESS_TABLE_PREFIX=admin
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
- PMA_HOST=db
- MYSQL_ROOT_PASSWORD=admin
volumes:
mysql_data:
driver: local
You can use one of the images tagged with cli, such as:
image: worpress:cli-php7.4
Find the list of available tags on Docker Hub
Related
I'm using Docker and a docker-compose.yml file to pop up a WordPress site using Bitnami and MariaDB. With just these two services alone, everything is fine, but I have no way to view/access the data in MariaDB. To solve the issue, I added the PHPMyAdmin service to the compose file since I'm familiar with that service. However, one of two problems happen: either all three services stay up and work fine and I can't login to PHPMyAdmin, or MariaDB shuts down every time immediately after starting up and the whole image doesn't work.
This configuration keeps the image up, but doesn't let me login to PHPMyAdmin...
services:
# Database
mariadb:
image: docker.io/bitnami/mariadb:latest
container_name: test_mariadb_database
volumes:
- 'mariadb_data:/bitnami/mariadb'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=test_bn_wp
- MARIADB_DATABASE=test_bitnami_wordpress
networks:
- test_bn
# phpmyadmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: test_pma
links:
- mariadb
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80
# Wordpress
wordpress:
image: docker.io/bitnami/wordpress:latest
ports:
- '80:8080'
- '443:8443'
restart: always
container_name: test_bitnami_wordpress
volumes: ['./docroot:/bitnami/wordpress']
depends_on:
- mariadb
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- WORDPRESS_DATABASE_HOST=mariadb
- WORDPRESS_DATABASE_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=test_bn_wp
- WORDPRESS_DATABASE_NAME=test_bitnami_wordpress
networks:
- test_bn
networks:
test_bn:
volumes:
mariadb_data:
driver: local
wordpress_data:
driver: local
So I change to this configuration, thinking that the password can't be blank, but it causes MariaDB to shut down immediately after starting up, thus rendering the whole image useless...
services:
# Database
mariadb:
image: docker.io/bitnami/mariadb:latest
container_name: test_mariadb_database
volumes:
- 'mariadb_data:/bitnami/mariadb'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=no
- MARIADB_USER=test_bn_wp
- MARIADB_PASSWORD=test_password
- MARIADB_ROOT_PASSWORD=test_password
- MARIADB_DATABASE=test_bitnami_wordpress
networks:
- test_bn
# phpmyadmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: test_pma
links:
- mariadb
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80
# Wordpress
wordpress:
image: docker.io/bitnami/wordpress:latest
ports:
- '80:8080'
- '443:8443'
restart: always
container_name: test_bitnami_wordpress
volumes: ['./docroot:/bitnami/wordpress']
depends_on:
- mariadb
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- WORDPRESS_DATABASE_HOST=mariadb
- WORDPRESS_DATABASE_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=test_bn_wp
- WORDPRESS_DATABASE_NAME=test_bitnami_wordpress
networks:
- test_bn
networks:
test_bn:
volumes:
mariadb_data:
driver: local
wordpress_data:
driver: local
Edit - This is the error I get when trying to login to PHPMyAdmin with the first config.
I see "table_name_connection" query instead of "table_name" in "query_root" section. The same hash appears instead of numeric IDs. Everything works in the first version, but this version is already deprecated.
Has anyone solved this problem?
MacOS, docker-compose.yml
version: '3.6'
services:
postgres:
image: postgres:12
restart: always
volumes:
- ./database:/var/lib/postgresql/data
ports:
- 5432:5432
environment:
POSTGRES_DB: ${PROJECT_NAME}
POSTGRES_PASSWORD: ${ADMIN_PASSWORD}
graphql-engine:
image: hasura/graphql-engine:v2.0.9
restart: always
volumes:
- ./database/hasura/metadata:/hasura-metadata
- ./database/hasura/migrations:/hasura-migrations
ports:
- 4321:8080
depends_on:
- "postgres"
environment:
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:${ADMIN_PASSWORD}#postgres:5432/${PROJECT_NAME}
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:${ADMIN_PASSWORD}#postgres:5432/${PROJECT_NAME}
# HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:${ADMIN_PASSWORD}#postgres:5432/${PROJECT_NAME}
HASURA_GRAPHQL_ENABLE_CONSOLE: ${DEV_MODE}
HASURA_GRAPHQL_DEV_MODE: ${DEV_MODE}
HASURA_GRAPHQL_ENABLED_LOG_TYPES: ${HASURA_LOGS}
HASURA_GRAPHQL_ADMIN_SECRET: ${ADMIN_PASSWORD}
You have enabled the relay api toggle:
I am having great trouble with this, Trying to add wp cli to my wordpress installation with docker-compose but cant get it done as im getting an error when trying to connect the two in docker compose - IM getting an error about duplicate volumes.
Can you see what this is?
version: '3.3'
services:
db:
image: mysql
restart: always
volumes:
- mysql_data:/var/lib/mysql
- ./database/init:/docker-entrypoint-initdb.d/:ro
environment:
- MYSQL_ROOT_PASSWORD=admin
- MYSQL_DATABASE=mydb_assdf
- MYSQL_USER=admin
- MYSQL_PASSWORD=admin
security_opt:
- seccomp:unconfined
wordpress:
image: wordpress
depends_on:
- db
- phpmyadmin
ports:
- '8000:80'
restart: always
volumes:
- ./wordpress:/var/www/html
- wp_data:/var/www/html
environment:
- WORDPRESS_DB_HOST=db:3306
- WORDPRESS_DB_USER=admin
- WORDPRESS_DB_PASSWORD=admin
- WORDPRESS_DB_NAME=mydb_assdf
- WORDPRESS_TABLE_PREFIX=adsf_
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
- PMA_HOST=db
- MYSQL_ROOT_PASSWORD=admin
wpcli:
image: wordpress:cli
restart: always
depends_on:
- wordpress
volumes:
- wp_data:/var/www/html
- ./default/:/var/www/html/wp-content
ports:
- '1111:80'
volumes:
mysql_data:
driver: local
wp_data:
driver: local
I am trying to create a multisite docker configuration and I am not sure how to proceed with the existing docker-compose.yml that I use. I have already it up so that I can spin up as many sites as I want using a network. Here is the shared docker-compose.yml for reference.
version: "3.3"
services:
photon:
image: "chriszarate/photon:latest"
mysql:
image: "mariadb:10.2"
container_name: "mysql-database"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: "wordpress"
MYSQL_ROOT_PASSWORD: ""
ports:
- "3306:3306"
restart: always
volumes:
- type: volume
source: dbdata
target: "/var/lib/mysql"
volume:
nocopy: true
#- "./sql:/docker-entrypoint-initdb.d"
adminer:
image: adminer
restart: always
ports:
- 8080:8080
proxy:
image: "jwilder/nginx-proxy:alpine"
container_name: "proxy"
environment:
HSTS: "off"
HTTPS_METHOD: "nohttps"
ports:
- "80:80"
- "443:443"
volumes:
- "//var/run/docker.sock:/tmp/docker.sock:ro"
- "./certs/self-signed:/etc/nginx/certs:ro"
- "./conf/nginx-proxy.conf:/etc/nginx/conf.d/proxy.conf:ro"
networks:
default:
external:
name: shared
volumes:
dbdata: {}
And here is the one that I use for sites.
version: "3.3"
services:
wordpress:
container_name: "wp"
image: "wordpress:${WP_VERSION:-4.9.7}-php${PHP_VERSION:-7.2}-apache"
environment:
VIRTUAL_HOST: "${DOCKER_DEV_DOMAIN:-project.test}"
WORDPRESS_DB_HOST: "mysql"
WORDPRESS_DB_NAME: "wordpress"
WORDPRESS_DB_PASSWORD: ""
WORDPRESS_DB_USER: "root"
external_links:
- mysql
volumes:
- "wp:/var/www/html:rw"
- "./certs/ca-root/ca.crt:/tmp/certs/root.crt:ro"
- "./conf/php-local.ini:/usr/local/etc/php/conf.d/local.ini:ro"
- "./conf/wp-local-config.php:/usr/local/etc/php/autoprepend.php:ro"
- "./src/vip-go-mu-plugins:/var/www/html/wp-content/mu-plugins"
- "./src/site1/client-mu-plugins:/var/www/html/wp-content/client-mu-plugins"
- "./src/site1/images:/var/www/html/wp-content/images"
- "./src/site1/languages:/var/www/html/wp-content/languages"
- "./src/site1/plugins:/var/www/html/wp-content/plugins"
- "./src/site1/private:/var/www/html/wp-content/private"
- "./src/site1/themes:/var/www/html/wp-content/themes"
- "./src/site1/vip-config:/var/www/html/wp-content/vip-config"
wp-cli:
container_name: "wp-cli"
image: "wordpress:cli-php${PHP_VERSION:-7.2}"
environment:
- APACHE_RUN_USER="www-data"
- APACHE_RUN_GROUP="www-data"
external_links:
- mysql
volumes:
- "wp:/var/www/html:rw"
- "./bin/install-wp.sh:/usr/local/bin/install-wp:ro"
- "./conf/php-local.ini:/usr/local/etc/php/conf.d/local.ini:ro"
- "./conf/wp-local-config.php:/usr/local/etc/php/autoprepend.php:ro"
- "./src/vip-go-mu-plugins:/var/www/html/wp-content/mu-plugins"
- "./src/site1/client-mu-plugins:/var/www/html/wp-content/client-mu-plugins"
- "./src/site1/images:/var/www/html/wp-content/images"
- "./src/site1/languages:/var/www/html/wp-content/languages"
- "./src/site1/plugins:/var/www/html/wp-content/plugins"
- "./src/site1/private:/var/www/html/wp-content/private"
- "./src/site1/themes:/var/www/html/wp-content/themes"
- "./src/site1/vip-config:/var/www/html/wp-content/vip-config"
networks:
default:
external:
name: shared
volumes:
wp: {}
This setup works fine for one site (any other sites I spin up when I make copies of the folder) and it replicates the environment that VIP Go has. But I am not sure what changes will be needed to make this work with multisite environment as each site will have a different folder when docker is spun up.
Any ideas?
TIA
Note: multisites will be different sites and not subdomains when it's set up in production so I need to keep it that way and not set up subdomains
I'm trying to set up a simple WordPress build using docker compose. However, when I build it, the volumes appear to be empty.
Here is my docker-compose.yml:
version: '3'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8000:80
volumes:
- ./development:/var/www/html
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
depends_on:
- db
networks:
- wordpress-network
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
ports:
- 8080:80
links:
- db:db
db:
image: mariadb:latest
ports:
- 127.0.0.1:3306:3306
command: [
'--default_authentication_plugin=mysql_native_password',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci'
]
volumes:
- wp-data:/var/lib/mysql
environment:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: password
networks:
- wordpress-network
networks:
wordpress-network:
driver: bridge
volumes:
wp-data:
driver: local
Here is my local project structure, with theme stylesheet:
I run docker-compose to build the image:
docker-compose up -d --build
But when I open the build in my browser, it looks like the theme is empty:
This leads me to believe the volume is empty. I'd appreciate any help or insights into this issue, thank you.
In your docker-compose file you say ./wp-data:/var/lib/mysql which is host folder mapping (not volume) but in your docker-compose you define docker named volume called wp-data and if you want to use this volume you have to use it as wp-data:/var/lib/mysql. I would also suggest to remove ${PWD} because it might cause problem in sh