How to run two frappe-bench in docker using containers

Continuing the discussion from How to run multiple host from multiple docker containers?:

I’m also tried to run two docker project at a same time im getting this error

 ✔ Container frappe_docker_erp15_1_devcontainer-redis-queue-1  Running     0.0s 
Error response from daemon: driver failed programming external connectivity on endpoint frappe_docker_erp15_1_devcontainer-frappe-1 (1c33ccc57727a3fc2ba9c7665561815b07e20760cbed581f68bba9bb02daa1ee): Bind for 0.0.0.0:9005 failed: port is already allocated
[2023-11-17T06:36:27.499Z] Stop (151 ms): Run: docker compose --project-name frappe_docker_erp15_1_devcontainer -f /home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1/.devcontainer/docker-compose.yml -f /home/softsuave/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.containerFeatures-1699539616344.yml up -d --no-recreate
[2023-11-17T06:36:27.499Z] Error: Command failed: docker compose --project-name frappe_docker_erp15_1_devcontainer -f /home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1/.devcontainer/docker-compose.yml -f /home/softsuave/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/docker-compose/docker-compose.devcontainer.containerFeatures-1699539616344.yml up -d --no-recreate
[2023-11-17T06:36:27.499Z]     at sAA (/home/softsuave/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:427:3165)
[2023-11-17T06:36:27.500Z]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[2023-11-17T06:36:27.500Z]     at async oAA (/home/softsuave/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:409:3170)
[2023-11-17T06:36:27.500Z]     at async NAA (/home/softsuave/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:479:3833)
[2023-11-17T06:36:27.500Z]     at async vC (/home/softsuave/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:479:4775)
[2023-11-17T06:36:27.500Z]     at async etA (/home/softsuave/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:613:10941)
[2023-11-17T06:36:27.500Z]     at async AtA (/home/softsuave/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:613:10682)
[2023-11-17T06:36:27.502Z] Stop (5603 ms): Run: /usr/share/code/code --ms-enable-electron-run-as-node /home/softsuave/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/softsuave/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-1fb89f28-09db-446e-90a4-6f6b0315a0891700202981293 --workspace-folder /home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1 --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1 --id-label devcontainer.config_file=/home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root
[2023-11-17T06:36:27.502Z] Exit code 1
[2023-11-17T06:36:27.505Z] Command failed: /usr/share/code/code --ms-enable-electron-run-as-node /home/softsuave/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/softsuave/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-1fb89f28-09db-446e-90a4-6f6b0315a0891700202981293 --workspace-folder /home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1 --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1 --id-label devcontainer.config_file=/home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/softsuave/_practice/erp/erp15/frappe_docker_erp15_1/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root
[2023-11-17T06:36:27.505Z] Exit code 1

I can spot this Bind for 0.0.0.0:9005 failed: port is already allocated

I can run this command to terminate that process Click here

sudo fuser -k 9005/tcp

but that port is already in use.

here the docker running container details

here my file details
common_site_config.json

{
 "background_workers": 1,
 "db_host": "mariadb",
 "default_site": "ss15-2.localhost",
 "file_watcher_port": 6787,
 "frappe_user": "frappe",
 "gunicorn_workers": 25,
 "live_reload": true,
 "rebase_on_pull": false,
 "redis_cache": "redis://redis-cache:6379",
 "redis_queue": "redis://redis-queue:6379",
 "redis_socketio": "redis://redis-queue:6379",
 "restart_supervisor_on_update": false,
 "restart_systemd_on_update": false,
 "serve_default_site": true,
 "shallow_clone": true,
 "socketio_port": 9001,
 "use_redis_auth": false,
 "webserver_port": 8001
}

Procfile


web: bench serve --port 8001

socketio: /home/frappe/.nvm/versions/node/v18.18.2/bin/node apps/frappe/socketio.js

watch: bench watch

schedule: bench schedule
worker: bench worker 1>> logs/worker.log 2>> logs/worker.error.log

docker-compose.yml

version: "3.7"
services:
  mariadb:
    image: docker.io/mariadb:10.6
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - --skip-character-set-client-handshake
      - --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6
    environment:
      MYSQL_ROOT_PASSWORD: 123
    volumes:
      - mariadb-data:/var/lib/mysql

  # Enable PostgreSQL only if you use it, see development/README.md for more information.
  # postgresql:
  #   image: postgres:11.8
  #   environment:
  #     POSTGRES_PASSWORD: 123
  #   volumes:
  #     - postgresql-data:/var/lib/postgresql/data

  redis-cache:
    image: docker.io/redis:alpine

  redis-queue:
    image: docker.io/redis:alpine

  frappe:
    image: docker.io/frappe/bench:latest
    command: sleep infinity
    environment:
      - SHELL=/bin/bash
    volumes:
      - ..:/workspace:cached
      # Enable if you require git cloning
      # - ${HOME}/.ssh:/home/frappe/.ssh
    working_dir: /workspace/development
    # ports:
    #   - 8000-8005:8000-8005
    #   - 9000-9005:9000-9005
    ports:
      - "8001:8001"
      - "9001:9001"
      - "6390:6390"
  # enable the below service if you need Cypress UI Tests to be executed
  # Before enabling ensure install_x11_deps.sh has been executed and display variable is exported.
  # Run install_x11_deps.sh again if DISPLAY is not set
  # ui-tester:
  #   # pass custom command to start Cypress otherwise it will use the entrypoint
  #   # specified in the Cypress Docker image.
  #   # also pass "--project <folder>" so that when Cypress opens
  #   # it can find file "cypress.json" and show integration specs
  #   # https://on.cypress.io/command-line#cypress-open
  #   entrypoint: 'sleep infinity'
  #   image: "docker.io/cypress/included:latest"
  #   environment:
  #     - SHELL=/bin/bash
  #     # get the IP address of the host machine and allow X11 to accept
  #     # incoming connections from that IP address
  #     #   IP=$(ipconfig getifaddr en0) or mac or \
  #     #   IP=$($(hostname -I | awk '{print $1}') )  for Ubuntu
  #     #   /usr/X11/bin/xhost + $IP
  #     # then pass the environment variable DISPLAY to show Cypress GUI on the host system
  #     #   DISPLAY=$IP:0
  #     - DISPLAY
  #   volumes:
  #     # for Cypress to communicate with the X11 server pass this socket file
  #     # in addition to any other mapped volumes
  #     - /tmp/.X11-unix:/tmp/.X11-unix
  #     - ..:/workspace:z,cached
  #   network_mode: "host"
volumes:
  mariadb-data:
  #postgresql-data:

Have to take build again

Its worked for me after done the all the changes after removed the old image and again build the new image its worked for me