Issue related to redis connection on compose when use with docker

When you run docker compose up -d container runs but fails loging that redis connection is not established that casuing issue to run in the server ubuntu to fix that redis port the number in a series

version: “3.7”
name: gameplan

services:
mariadb:
image: 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

redis:
image: redis:alpine
ports:
- “6379:6379”

frappe:
image: frappe/bench:latest
command: bash /workspace/init.sh
environment:
SHELL: /bin/bash
REDIS_CACHE: redis://redis:6379/0
REDIS_QUEUE: redis://redis:6379/1
REDIS_SOCKETIO: redis://redis:6379/2
working_dir: /home/frappe
volumes:
- .:/workspace
ports:
- 8000:8000
- 9000:9000
depends_on:
- mariadb
- redis

volumes:
mariadb-data:

updated init.sh

#!bin/bash

if [ -d “/home/frappe/frappe-bench/apps/frappe” ]; then
echo “Bench already exists, skipping init”
cd frappe-bench
bench start
else
echo “Creating new bench…”
fi

bench init --skip-redis-config-generation frappe-bench

cd frappe-bench

Use containers instead of localhost with proper URL

bench set-mariadb-host mariadb
bench set-redis-cache-host $REDIS_CACHE
bench set-redis-queue-host $REDIS_QUEUE
bench set-redis-socketio-host $REDIS_SOCKETIO

Remove redis, watch from Procfile

sed -i ‘/redis/d’ ./Procfile
sed -i ‘/watch/d’ ./Procfile

bench get-app gameplan

bench new-site gameplan.localhost
–force
–mariadb-root-password 123
–admin-password admin
–no-mariadb-socket

bench --site gameplan.localhost install-app gameplan
bench --site gameplan.localhost set-config developer_mode 1
bench --site gameplan.localhost clear-cache
bench --site gameplan.localhost set-config mute_emails 1
bench --site gameplan.localhost add-user alex@example.com --first-name Alex --last-name Scott --password 123 --user-type ‘System User’ --add-role ‘Gameplan Admin’
bench use gameplan.localhost

bench start

will fix the issue on installation