Here is sample docker compose configuration for bringing up a simple directory listing service(dirlist):
version: "3"
services:
dirlist:
image: ubuntu-python
networks:
app_net:
ipv4_address: "172.19.0.10"
hostname: maca
volumes:
- /home/arun/misc:/misc
working_dir: /misc
curlcmd:
image: ubuntu-curl
command: curl -s http://maca:8000/readme1.txt
extra_hosts:
- "maca:172.19.0.10"
depends_on:
- web
networks:
app_net:
networks:
app_net:
ipam:
driver: default
config:
- subnet: "172.19.0.0/24"
I want to create replicas of dirlist such that each containers spawned thereof have the following:
- ip addresses should be serial. For e.g. 1st container must have ip address
172.19.0.10, 2nd one -172.19.0.11, 3rd -172.19.0.12, and, so on...Ip addresses being selected randomly from a range is also okay, however, #3 requirement should also be met. - Their hostnames should also appear to have serial pattern - say the 1st container has
dirlist1as hostname, 2nd one hasdirlist2, etc... - All such containers (of
dirlist) should also appear asextra_hosts(with their corresponding names and ip addresses) for the service which depend ondirlist(i.e.curlcmdas per example).