Reputation: 2690
I try to have a full wordpress service working on a container with mariaDB and PHPMyAdmin. I can only find outdated (like v1 docker-compose) help online.
I try with this docker-compose.yml file :
Edited files:
version: '2'
services:
wordpress:
image: wordpress:latest
networks:
- front
- back
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: wpdb
WORDPRESS_TABLE_PREFIX: wp_
WORDPRESS_DB_HOST: wordpress_db
volumes:
- ./wordpress-data:/var/www/html
- ./php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
wordpress_db:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: examplepass
volumes:
- wordpress-db-data:/var/lib/mysql
networks:
- back
phpmyadmin:
image: phpmyadmin/phpmyadmin
networks:
- back
ports:
- 8181:80
volumes:
wordpress-db-data:
driver: local
networks:
front:
back:
I can hit PHPMA on 8181 but I cannot hit WP on 8080.
Any idea ?
EDIT: I made some change. WP is running now but I cannot connect my user root/examplepass to PMAdmin.
I have an error like this
#2002 - php_network_getaddresses: getaddrinfo failed: Name does not resolve — The server is not responding (or the local server's socket is not correctly configured).
Upvotes: 1
Views: 2592
Reputation: 2690
I finally got it.
I need the var env PMA_HOST: wordpress_db
on PMA.
So my final .yml file :
version: '2'
services:
wordpress:
image: wordpress:latest
networks:
- front
- back
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: wpdb
WORDPRESS_TABLE_PREFIX: wp_
WORDPRESS_DB_HOST: wordpress_db
volumes:
- ./wordpress-data:/var/www/html
- ./php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
wordpress_db:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: examplepass
volumes:
- wordpress-db-data:/var/lib/mysql
networks:
- back
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
networks:
- back
ports:
- 8181:80
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: examplepass
PMA_HOST: wordpress_db
volumes:
wordpress-db-data:
driver: local
networks:
front:
back:
Upvotes: 1
Reputation: 1028
Honestly I think you're approaching this wrong. The best way is to set all the environment variables on the DB container so that it (a) provisions the accounts and DB, and then link it to the web container.
Once the web container starts, it will have access to the MYSQL_... variables since they were derived on the DB container. Start with The DB container, link to wordpress, then link DB to PHPMyadmin as well.
Upvotes: 1