Networking Between Docker Containers

If you don't want to use a docker-compose file for whatever reason you can create networking between containers manually.

circle-info

This can be achieved only on the same network!

How to set networking for DecisionRules in docker

How to setup multi-container app

What containers will we need:

  1. Server App

  2. Client App

  3. Business Intelligence App

  4. Redis

  5. MongoDB

Method 1: Setup with terminal

First of all, we need to create a docker network because containers, by default, don't see other containers thus they cannot communicate with each other. We will use a simple command docker network create

triangle-exclamation
// creating docker network space
docker network create <network_name>

// if you want to remove network
docker network remove <network_name>

In the second step, we need to run all mandatory containers mentioned above. We will do it with the help of docker run . In this command, we will set ports and env variables as well.

circle-check
circle-info

-d flags that can be interpreted as-d -pwhich is a detached mode with exposed ports. Detached mode means that the container runs in the background and grimly does its work.

circle-exclamation
circle-check

Method 2: Setup with docker-compose file

You can use docker-compose for a very easy setup.

circle-info

Run docker-compose with docker compose up command

Last updated