I have a docker-compose file that specifies two containers which are to be created in two separate networks:
- A mysql database -- this contains the adventureworks data (and belongs to
adventureworks-db-nwnetwork). - A java based webapp -- this talks to the mysql database to perform CRUD operations (and belongs to
adventureworks-app-nwnetwork).
version: '3'
services:
adventureworks-db:
image: mysql
container_name: adventureworks-db
networks:
- adventureworks-db-nw
ports:
- 3306:3306
adventureworks-app:
container_name: adventureworks-app
networks:
- adventureworks-app-nw
ports:
- 8080:8080
networks:
adventureworks-db-nw:
driver: bridge
adventureworks-app-nw:
driver: bridge
For brevity, I have omitted certain parts of the docker-compose.yml file that will perhaps not be relevant to the question I have.
How can I get the java webapp in adventureworks-app container, that belongs to the adventureworks-app-nw to talk to the mysql database in adventureworks-db container, that belongs to the adventureworks-db-nw network?
Please note that I want to maintain the separation of these two networks as two separate custom (user-created) docker networks.