creaprog
(Creaprog)
September 17, 2018, 8:43pm
1
Hello,
I have 1 problem with Docker, with mariadb for Wordpress I have this error : MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known
The logs: https://pastebin.com/G22frUaa
My docker-compose :
version: ‘3.3’
services:
wordpress:
image: wordpress:latest
restart: always
environment:
WORDPRESS_DB_PASSWORD: wordpress
networks:
local:
proxy:
aliases:
- wordpress
volumes:
- ./html:/var/www/html
depends_on:
- mariadb
- memcached
mariadb:
image: mariadb:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
volumes:
- ./database:/var/lib/mysql
networks:
- local
memcached:
image: memcached
restart: always
networks:
- local
networks:
proxy:
external: true
local:
external: false
How to solve the problem ?
thx
terpz
(Martin Terp)
September 17, 2018, 9:08pm
2
Hi
At the wordpress installer, what do you type in as a database hostname?
also, in your wordpress “networks” attr, you typed in:
networks:
local:
should be:
networks:
- local
also, try and rename/alias your mariadb container to “mysql”, or add the env:
WORDPRESS_DB_HOST: mariadb
to your wordpress container
creaprog
(Creaprog)
September 18, 2018, 4:12pm
3
If I change “local:” to “- local” : ERROR: yaml.parser.ParserError: while parsing a block collection
in “./docker-compose.yml”, line 11, column 7
With “WORDPRESS_DB_HOST: mariadb” problem resolved.
THX
1 Like
rlevilla
(raphael levillain)
October 19, 2024, 8:31pm
4
Hello, i have a really similare issues but a little bit different so i cannot fix it.
I have one container with nginx, one with wordpress and php-fpm and a last one with mariadb.
when i try this command line :./wp-cli.phar config create --dbname=db_wordpress --dbuser=buakaw --dbpass=buakaw --dbhost=mariadb --path=/var/www/html/ --allow-root --force
i have this error :
PHP Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in phar:///var/www/html/wp-cli.phar/vendor/wp-cli/config-command/src/Config_Command.php on line 234
here’s my docker compose file :
services:
nginx:
build: ./requirements/nginx/.
container_name: nginx
ports:
- 443:443
restart: always
networks:
- inception
volumes:
- ./web:/var/www/html
wordpress:
depends_on:
- mariadb
build: ./requirements/wordpress/.
container_name: wordpress
expose:
- "9000"
restart: always
networks:
- inception
volumes:
- ./web:/var/www/html/
environment:
- WP_HOST=mariadb
- WP_DB_USER=buakaw
- WP_DB_PASSWORD=buakaw
- WP_DB_NAME=db_wordpress
mariadb:
build: ./requirements/mariadb/.
container_name: mariadb
ports:
- "3306"
restart: always
networks:
- inception
volumes:
- ./web:/var/www/html/
environment:
- MYSQL_ROOT_PASSWORD=buakaw
- MYSQL_USER=buakaw
- MYSQL_PASSWORD=buakaw
- MYSQL_DATABASE=db_wordpress
networks:
inception:
driver: bridge
and here the script i lunch to config the wordpress database:
#!/bin/bash
mkdir -p /var/www/html
cd /var/www/html
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -P /var/www/
chmod +x wp-cli.phar
./wp-cli.phar core download --allow-root
./wp-cli.phar config create --dbname=db_wordpress --dbuser=buakaw --dbpass=buakaw --dbhost=mariadb --path=/var/www/html/ --allow-root --force
./wp-cli.phar core install --url=${WP_HOME_URL}--title=${WP_BLOG_TITLE} --admin_user=${WP_ADMIN_USER} --admin_password=${WP_ADMIN_PASS} --admin_email=${WP_ADMIN_EMAIL} --allow-root
php-fpm7.4 -F