Hi Guys.
i got a raspberry pi 3 running docker and i would like to create a private wordpress website abailable only on my private newtwork.
What i want to do is set up a container for wordpress and another one for the database (mysql).
i also want to create some volumes to save all the configurations in case i would need to delete the containers.
So i started to create a docker-compose file and i seems my too containers cannot communicate to each other.
Here is the file :
version: '3.7'
services:
wordpress:
depends_on:
- db
links:
- db
image: wordpress
container_name: wordpress_web
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: WP-User
WORDPRESS_DB_PASSWORD: WP-password
WORDPRESS_DB_NAME: databasename
networks:
- wordpress-network
volumes:
- 'wordpress_data:/var/www/html'
db:
image: hypriot/rpi-mysql
container_name: wordpress_database
restart: always
environment:
MYSQL_DATABASE: databasename
MYSQL_USER: WP-User
MYSQL_PASSWORD: WP-password
MYSQL_ROOT_PASSWORD: root-password
networks:
- wordpress-network
volumes:
- 'db_data:/var/lib/mysql'
volumes:
wordpress_data:
driver: local
driver_opts:
type: nfs
o: addr=192.168.**.**,rw
device: ":/*****/*****/wordpress/var/www/html"
db_data:
driver: local
driver_opts:
type: nfs
o: addr=192.168.**.**,rw
device: ":/*****/*****/wordpress/var/lib/mysql"
networks:
wordpress-network:
driver: bridge
ipam:
config:
- subnet: IP / SUBNET MASK
When i try this i got an error telling me that’s it’s impossible to contact the database.
When i remove wordpress “environment” part, i can see the web site but it still cannot communicate with the database container.
Can you help me to sole this problem ?
I’m sorry if this is a stupid question but i’m new with docker and i didn’t find anything online about this.
Thx a lot for your help.