Docker Community Forums

Share and learn in the Docker community.

MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known with MariaDB


(Creaprog) #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 :slight_smile:


(Martin Terp) #2

Hi :slight_smile:

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) #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 :slight_smile: