How to run multiple host from multiple docker containers?

Hi, @revant_one and community,
I am not able to expose multiple hosts from multiple docker containers (using the same but with different ports docker-compose file) in a particular EC2 instance in the development setup.

Note: Both created containers are accesses by different Linux users, so I am using the same docker-compose file, but only ports changed [difference mentioned below].

Getting errors that ports are already in use.

System Specs:-
Ubuntu 18.04 LTS machine over EC2 instance

I am using frappe/bench: latest for container build. Take a look at the docker-compose.yml file.

version: "3.7"
services:
  mariadb:
    image: mariadb:10.3
    environment:
      - MYSQL_ROOT_PASSWORD=123
      - MYSQL_USER=root
    volumes:
      - ./installation/frappe-mariadb.cnf:/etc/mysql/conf.d/frappe.cnf
      - mariadb-vol:/var/lib/mysql
    command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', '--skip-character-set-client-handshake']

  redis-cache:
    image: redis:alpine

  redis-queue:
    image: redis:alpine`Preformatted text`

  redis-socketio:
    image: redis:alpine

  frappe:
    image: frappe/bench:latest
    command: sleep infinity
    volumes:
      - ..:/workspace:cached
    working_dir: /workspace/development
    ports:
      - "8000:8000"
      - "9000:9000"
      - "6379:6379"

volumes:
  mariadb-vol:
  postgresql-vol:

and 2nd docker-compose.yml file only difference is

      ports:
      - "8001:8001"
      - "9001:9001"
      - "6390:6390"

External hosts -
1st - <host_name>: 8000
2nd - <host_name>: 8001

Only one out of multiple (here two) hosts able to access.

Please also suggest any approach to run it. (Can be an alternative approach to it)

Thanks
Vijendra

which ports are already running? resolve that conflict and it should work.

Hi @revant_one,
I am able to use one host at port 8000, but not able to run another one (8001) which is forwarded from another docker container.

Have a look at the screenshots for more info.

Host from container-1 is running on port 8000

but, the host from container-2 isn’t showing anything in the browser with **port 8001** (which mapped in the docker-compose file, look at the above comment for both container’s port mapping
How to run multiple host from multiple docker containers?)

Is there any workaround common_site_config.json? As I also tried to change web_server from 8000 default to 8001. [Inside container-2]

Finally, the point is I am not able to expose the host on port 8001 (from another container-2)

Thanks
Vijendra

common_site_config.json just stores the config.

bench setup procfile will generate Procfile from given config.

Alternatively, edit the Procfile file manually and set the bench serve port to 8001.

also set the socketio port to 9001 in common_site_config.json or it will conflict with other running socket io on 9000

1 Like

Thanks @revant_one, It works for me.