Answer the question
In order to leave comments, you need to log in
Single database for api and web in docker?
Good afternoon.
There are 2 working applications:
- api written in lumen for mob. applications
- web application on laravel
They are in different repositories, and CI / CD is configured for them. They use a single base.
Set up docker-compose in the web application (4 php, nginx, mysql, redis services). Launched, everything works as it should.
The question is how to specify in api in docker-compose what would use the existing base container?
Answer the question
In order to leave comments, you need to log in
To solve this problem, you need to create an additional network, with the bridge driver , in the stack with the services you want to provide access to (connect to).
After creating the network, you need to specify which containers should connect to the network during startup in order to access them from another stack.
Example:
docker-compose.laravel.yml
services:
mysql:
image: ...
networks:
- default
- my_private_network
redis:
image: ...
networks:
- default
- my_private_network
networks:
my_private_network:
name: my_private_network
driver: bridge
php-fpm:
image: ...
networks:
- default
- my_private_network
networks:
my_private_network:
external: true
name: my_private_network
DB_HOST=mysql
REDIS_HOST=redis
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question