In this example we are going to create two networks and one container in each. Our aim is to make one container access the other one.

Structure

There are two networks - web_net_1 and web_net_2. There are also two container - app_1_con and app_2_con. The web_net_2 will host both containers but web_net_1 will host only app_1_con. Just because app_1_con is part of web_net_2 network, it can communicate with app_2_con.

#docker #dockerfile

Dockerfile Example for Two Containers Communicating with Each
1.20 GEEK