Question

Hi, I am facing issue with creating multiple containers from the same imagee.

Posted July 28, 2021 109 views
DockerCI/CD

Currently, I am able to the same but with only one container by assigning static ip addresses to the container. Not sure how to implement this for multiple ones. Each rtu needs to have a diff IP adress and be associated with a ctrl unit. This ctrl unit is then connected to a network, linked to a gateway.

services:
  rtu_a:
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"
    image: ${REGISTRY_PREFIX}testbed/modbus${REGISTRY_TAG}
    volumes:
      - ./volume:/var/lib/my_volume
    build:
      context: .
      cache_from:
        - ${REGISTRY_PREFIX}modbus${REGISTRY_TAG}
        - ${REGISTRY_PREFIX}modbus:${CI_COMMIT_REF_SLUG}
        - ${REGISTRY_PREFIX}modbus:master
    networks:
      rtu-ctrl-net-a:
        ipv4_address: 172.31.0.101
    command: python3 rtu_unit.py "rtu_a"

  ctrl_unit_a:
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"
    image: ${REGISTRY_PREFIX}testbed/modbus${REGISTRY_TAG}
    volumes:
      - ./volume:/var/lib/my_volume
    depends_on:
      - rtu_a
    networks:
      rtu-ctrl-net-a:
        ipv4_address: 172.31.0.102
    command: python3 ctrl_unit.py rtu_a 1 "ctrl_unit_a"

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Im not expert on this but I think you need to fix the network it self and connections