How to start multiple bot in one docker-compose

Hey guys. I am experimenting to see if it is possible to start multiple bots (listening to different port) by simple executing one docker-compose.

However I met a problem: I found that in the base Docker image (for example: Docker Hub), it s already allocated a port by EXPOSE, which is 5005. And I dont know how to override it in docker-compose.yml. This would be a problem if I run two bots in the same docker-compose, the error is:

ERROR: for mq-bot_action_server  Cannot start service mq-bot_action_server: driver failed programming external connectivity on endpoint all-in-one_mq-bot_action_server_1 (3671e9d372612e4f9283a18bcd82f14930801b75a68488e40135ba26b8103fab): Bind for 0.0.0.0:5055 failed: port is already allocated

Did anyone successfully run multiple bot in one docker-compose before? Or is this even a right direction?

My docker-compose.yml is:

version: '3.0'
services:
  mq-seq-bot:
    image: rasa/rasa:latest-full
    ports:
      - 5005:5005
    volumes:
      - ./mq-seq-bot:/app
    command:
      - run

  mq-seq-bot_action_server:
    image: rasa/rasa-sdk:latest
    volumes:
      - ./mq-seq-bot/actions:/app/actions
    ports:
      - 5055:5055
  
  mq-bot:
    image: rasa/rasa:latest-full
    ports:
      - 5006:5006
    volumes:
      - ./mq-bot:/app
    command:
      - run
    # command: >
      # run -m /app/mq-bot/models --debug --endpoints /app/mq-bot/endpoints.yml

  mq-bot_action_server:
    image: rasa/rasa-sdk:latest
    volumes:
      - ./mq-bot/actions:/app/actions
    ports:
      - 5056:5056

and actually the ports does not work. All the bots with image rasa/rasa are running at 5005, and all the action server are running at 5055.

Hey @luofanghao! :relaxed:

Have you tried perhaps setting the ports on the ‘rasa run’ command option for each bot service? So each server will start on the ports you want, instead of the default 5005. Like this (just replacing the --p values):

  mq-bot:
    image: rasa/rasa:latest-full
    volumes:
      - ./mq-bot:/app
    command: rasa run --p 5006 

It might help when wanting to use different ports from what was exposed previously. Hope it helps!

Thank you, it works!

Okay I found the reason is because I was not familiar with Docker. I am using these two as my base docker images:

https://hub.docker.com/r/rasa/rasa/dockerfile

https://hub.docker.com/r/rasa/rasa-sdk/dockerfile

So if you take a look you will find it pre-defined the port. To change the port, just override the CMD. For rasa/rasa, it is run -p 5006, for rasa-sdk, it is start --actions actions.actions -p 5056

1 Like

Hello, how did you organize your project in the /etc/ ? do you have separate folder for each bot project or ? if thats the case where did you run the docker compose

Here is example of mine system. Hope it helps
Directory

[paulii@vetbot-v4 /rasaProd TUOTANTO]$ ll
total 64
drwxrwxr-x 15 paulii paulii 4096 Oct 27 16:13 ./
drwxrwxr-x  4 paulii paulii 4096 Apr 14  2021 ../
drwxrwxr-x  6 paulii paulii 4096 Oct 27 16:23 IIpilleribot/
drwxrwxr-x  6 paulii paulii 4096 Oct 28 11:27 amva/
drwxrwxr-x  6 paulii paulii 4096 Aug 13 16:49 aspa/
-rw-rw-r--  1 paulii paulii 2976 Oct 27 09:47 docker-compose.yml
drwxrwxr-x  6 paulii paulii 4096 Sep 16 13:23 esari/
drwxrwxr-x  6 paulii paulii 4096 Oct 29 17:16 esihoks/
drwxrwxr-x  6 paulii paulii 4096 Oct 29 14:45 hyvment/
drwxrwxr-x  7 paulii paulii 4096 Oct  8 10:11 ittuki/
drwxrwxr-x  6 paulii paulii 4096 Aug 13 16:52 laakebot/
drwxrwxr-x  6 paulii paulii 4096 Oct 11 09:35 pilleribot/
drwxrwxr-x  6 paulii paulii 4096 Oct 29 17:08 sakky/
drwxrwxr-x  6 paulii paulii 4096 Aug  5 09:53 syobot/
drwxrwxr-x  6 paulii paulii 4096 Jun  3 12:30 talhal/
drwxrwxr-x  6 paulii paulii 4096 May 19 16:04 vetbot/

and
docker-compose.yml

[paulii@vetbot-v4 /rasaProd TUOTANTO]$ cat docker-compose.yml
version: '3.0'
services:
  amva:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5011:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/amva/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  aspa:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5005:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/aspa/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  hyvment:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5015:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/hyvment/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  ittuki:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5012:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/ittuki/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  sakky:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5006:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/sakky/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  vetbot:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5008:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/vetbot/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug


  vetbot:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5008:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/vetbot/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  laakebot:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5010:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/laakebot/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  syobot:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5009:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/syobot/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  esihoks:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5016:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/esihoks/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug

  pilleribot:
    image: rasa/rasa:2.2.0-full
    restart: always
    ports:
      - 5013:5005
    volumes:
      - /home/paulii/rasa2Prod/rasaProd/IIpilleribot/:/app
    command:
     - run
     - -m
     - models
     - --enable-api
     - --cors
     - "*"
     - --debug


1 Like