Get database address with Docker

admin

Administrator
Staff member
I use docker-compose with the following
Code:
docker-compose.yml
:

Code:
web_db:
   image: mariadb:latest
   restart: always
   volumes:
    - ./var/mysql:/var/lib/mysql
   environment:
    MYSQL_ROOT_PASSWORD: X
    MYSQL_DATABASE: wordpress
    MYSQL_USER: wordpress
    MYSQL_PASSWORD: X
    MYSQL_ROOT_PASSWORD: X

web_front:
  image: nginx
  restart: always
  ports:
    - 80:80
  links:
    - web_fpm
  volumes:
    - ./www:/var/www/html:rw
    - ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro

web_fpm:
  build: ./PHP-FPM/
  restart: always
  links:
    - web_db:mysql
  volumes:
    - ./www:/var/www/html

When configuring Wordpress (manually downloaded in nginx root directory), I'm asked for the address of the database. I've tried
Code:
localhost
, but it doesn't work.

PS: I know there are Wordpress images for Docker, but they have the full stack (nginx + PHP) and I don't like it, so don't propose them. ;)