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