2

I want to run 12 separate servers on a private network. What I mean is the end goal would be I can access static local ip addresses such as:

192.168.0.31
192.168.0.32
...
192.168.0.42

But I would like to manage this by having them all be run as separate docker containers on one machine.

I have done some previous research on this and I read into docker network create but I wasn't entirely sure that was the correct way to go about doing this.

If anyone could provide some guidance for this that would be great.

swarajd
  • 121
  • 1

1 Answers1

1

You should take a look at docker-compose https://docs.docker.com/compose/networking/ this will help you manage multiple containers and their network. For example here's a minimal docker-compose.yml to give you an idea. Once you have your docker-compose.yml configured you can simply run docker-compose up and all of your services (containers) will start connected to the network defined at the bottom of the docker-compose.yml.

version: '2'

services:
  container1:
    container_name: container2
    image: node:latest
    networks:
      my_network:
        ipv4_address: 10.0.0.2

  container2:
    container_name: container2
    build: node:latest
    networks:
      my_network:
        ipv4_address: 10.0.0.3

  container3:
    container_name: container3
    build: node:latest
    networks:
      my_network:
        ipv4_address: 10.0.0.4

  container4:
    container_name: container4
    build: node:latest
    networks:
      my_network:
        ipv4_address: 10.0.0.5

networks:
  my_network:
    driver: bridge
    ipam:
     config:
       - subnet: 10.0.0.0/16
         gateway: 10.0.0.1

The docker-network create command you mentioned is equivalent to the last step in this docker-compose.yml.

Snarf
  • 111
  • 5