ERPNext Docker , how to run site in second bench?

Hi,
Reference document: frappe_docker/single-server-example.md at main · frappe/frappe_docker · GitHub

I have followed the document and everything running successfully, except when I am doing the Create second bench section
the containers also up running, but I don’t know to to access the site ran by second bench, do i need to change or update the IP address or Port to the second bench?

my hosts

127.0.1.1 103cafe.local # ran successfully at first bench
127.0.1.1  103cafekps.local # I got `103cafekps.local` not found , but I have created in second bench
docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED       STATUS                 PORTS                               NAMES
c1a63a88ed7b   traefik:v2.6              "/entrypoint.sh --pr…"   2 hours ago   Up 2 hours             0.0.0.0:80->80/tcp, :::80->80/tcp   traefik-traefik-1
e981be9dd252   frappe/erpnext:v14.23.0   "bench worker --queu…"   3 hours ago   Up 46 minutes                                              erpnext-two-queue-default-1
85f79fa14403   frappe/erpnext:v14.23.0   "bench worker --queu…"   3 hours ago   Up 46 minutes                                              erpnext-two-queue-short-1
b2b4f49f2739   frappe/erpnext:v14.23.0   "bench schedule"         3 hours ago   Up 46 minutes                                              erpnext-two-scheduler-1
a3d16f2dc6be   frappe/erpnext:v14.23.0   "bench worker --queu…"   3 hours ago   Up 46 minutes                                              erpnext-two-queue-long-1
2e11baab581b   frappe/erpnext:v14.23.0   "node /home/frappe/f…"   3 hours ago   Up 46 minutes                                              erpnext-two-websocket-1
75bfa869c857   frappe/erpnext:v14.23.0   "/home/frappe/frappe…"   3 hours ago   Up 46 minutes                                              erpnext-two-backend-1
0759281d199d   redis:6.2-alpine          "docker-entrypoint.s…"   3 hours ago   Up 46 minutes          6379/tcp                            erpnext-two-redis-queue-1
a8e5f96f9b67   redis:6.2-alpine          "docker-entrypoint.s…"   3 hours ago   Up 46 minutes          6379/tcp                            erpnext-two-redis-cache-1
6ac8a180cfa4   redis:6.2-alpine          "docker-entrypoint.s…"   3 hours ago   Up 46 minutes          6379/tcp                            erpnext-two-redis-socketio-1
ffdad34b4986   frappe/erpnext:v14.23.0   "nginx-entrypoint.sh"    4 hours ago   Up 4 hours                                                 erpnext-one-frontend-1
abd428a3a82c   frappe/erpnext:v14.23.0   "bench worker --queu…"   4 hours ago   Up 4 hours                                                 erpnext-one-queue-long-1
efde478af2de   frappe/erpnext:v14.23.0   "bench schedule"         4 hours ago   Up 4 hours                                                 erpnext-one-scheduler-1
dbca8a9f5f71   frappe/erpnext:v14.23.0   "/home/frappe/frappe…"   4 hours ago   Up 4 hours                                                 erpnext-one-backend-1
3a460be00c08   frappe/erpnext:v14.23.0   "bench worker --queu…"   4 hours ago   Up 4 hours                                                 erpnext-one-queue-default-1
e6eca5db4e06   frappe/erpnext:v14.23.0   "node /home/frappe/f…"   4 hours ago   Up 4 hours                                                 erpnext-one-websocket-1
3814a71f5468   frappe/erpnext:v14.23.0   "bench worker --queu…"   4 hours ago   Up 4 hours                                                 erpnext-one-queue-short-1
171c4af4426d   redis:6.2-alpine          "docker-entrypoint.s…"   4 hours ago   Up 4 hours             6379/tcp                            erpnext-one-redis-cache-1
839a772c9c40   redis:6.2-alpine          "docker-entrypoint.s…"   4 hours ago   Up 4 hours             6379/tcp                            erpnext-one-redis-queue-1
e7bcac90ef18   redis:6.2-alpine          "docker-entrypoint.s…"   4 hours ago   Up 4 hours             6379/tcp                            erpnext-one-redis-socketio-1
4f09c362bbe0   mariadb:10.6              "docker-entrypoint.s…"   4 hours ago   Up 4 hours (healthy)   3306/tcp                            mariadb-database

and here is my step for Second Bench

docker compose --project-name traefik-two \
  --env-file ~/gitops/traefik-two.env \
  -f overrides/compose.traefik.yaml up -d
curl -sL https://raw.githubusercontent.com/frappe/frappe_docker/main/example.env -o ~/gitops/erpnext-two.env
sed -i 's/DB_PASSWORD=123/DB_PASSWORD=StrongPassw0rd/g' ~/gitops/erpnext-two.env
sed -i 's/DB_HOST=/DB_HOST=mariadb-database/g' ~/gitops/erpnext-two.env
sed -i 's/DB_PORT=/DB_PORT=3306/g' ~/gitops/erpnext-two.env
echo "ROUTER=erpnext-two" >> ~/gitops/erpnext-two.env
echo "SITES=\`103cafekps.local\`" >> ~/gitops/erpnext-two.env
echo "BENCH_NETWORK=erpnext-two" >> ~/gitops/erpnext-two.env

docker compose --project-name erpnext-two \
  --env-file ~/gitops/erpnext-two.env \
  -f compose.yaml \
  -f overrides/compose.redis.yaml \
  -f overrides/compose.multi-bench.yaml config > ~/gitops/erpnext-two.yaml

docker compose --project-name erpnext-two -f ~/gitops/erpnext-two.yaml up -d

docker compose --project-name erpnext-two exec backend \
  bench new-site 103cafekps.local --no-mariadb-socket --mariadb-root-password StrongPassw0rd --install-app erpnext --admin-password StrongPassw0rd

Thanks

Traefik acts as the main ingress/load balancer for all the docker compose projects installed on the server. With right labels configured the you should be able to access the site by visiting it in browser.

I don’t use docker compose, I use docker swarm. I use this for multiple benches and multiple sites custom_containers/docs/docker-swarm.md at main · castlecraft/custom_containers · GitHub

I copied the base traefik and portainer setup from dockerswarm.rocks. I don’t think it will work for anyone who is not already a user of dockerswarm.rocks guide.

1 Like

@revant_one , thanks for your kind support.

Sorry, What do you mean with the right label? it might give me some tricks.

thanks for your propose about docker-swarm, but I am not good at this, I may not go to this option.

In addition: if I go to inside the docker container bash of a second bench then I issue the command

  1. bench --site site_name serve --port port_number → to make it running manually

  2. update /etc/hosts which included

    ip-address-at-# 103cafekps.local

Then my site is working , but I should not keep it running like this.

Thanks, finally I got it work at production for multi-bench, ssl

Thanks @revant_one