you need to define networks and connect them to each other:
as an example
services:
app:
container_name: "app-fpm"
build:
context: ./app
volumes:
- ./data/mysql/:/var/lib/mysql/
- ./data/run/mysqld:/run/mysqld
- ./data/run/php:/run/php/
- ./data/run/clamd:/var/run/clamd/
- ./data/tmp:/tmp
- ./app/php/fpm/php.ini:/etc/php/7.2/fpm/php.ini
- ./app/app-entrypoint.sh:/app-entrypoint.sh
links:
- "mongodb:mongodb"
- "memcached:memcached"
networks:
- dbnet
depends_on:
- web
- mariadb
- mongodb
- memcached
mariadb:
container_name: "app-mysql"
build:
context: mariadb
image: mariadb:tag
volumes:
- ./mariadb/my.cnf:/etc/mysql/my.cnf
- ./data/mysql/data:/var/lib/mysql
- ./data/run/mysqld:/run/mysqld
- ./mariadb/app-entrypoint.sh:/app-entrypoint.sh
ports:
- "53306:3306"
networks:
- dbnet