Question

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

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"

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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