1 year ago
#338043
varun_koganti
Error establishing a database connection - Docker Wordpress & mysql setup
I am trying to set up a wordpress docker container on a raspberry pi zero. whey I browse IPv4 address of my raspberry pi zero i get following on the browser
Error establishing a database connection
firstly RAM usage after running both containers
pi@web-server:~/website $ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e1cf99c5422b website_wordpress "docker-entrypoint.s…" 44 seconds ago Up 28 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp wordpress_container
ff2fdee991fc website_db "/entrypoint.sh mysq…" 35 minutes ago Up 30 seconds 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp db
And finally my docker compose file "dockercompose.yaml"
version: "3.9"
services:
db:
build: ./db
container_name: db
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: y4e8kane
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: y4e8kane
networks:
website_network:
aliases:
- wordpress
wordpress:
build: .
container_name: wordpress_container
ports:
- "80:80"
networks:
website_network:
aliases:
- wordpress
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSOWRD: y4e8kane
WORDPRESS_DB_NAME: wordpress
networks:
website_network:
name: website_network
volumes:
db_data:
driver: local
name: db_data
I just have 2 dockerfiles in different dir, on same level di as docker-compose file I have one docker file related to wordpress and on {current_dir}/db i ahve another dockerfile related to mysql db
mysql
wordpress
docker
raspbian
raspberry-pi-zero
0 Answers
Your Answer