Unable to start mysql 8.2.0 via docker compose command – Docker Desktop

I am trying to build a customize mysql docker image and start it with docker compose command as follows:

The Dockerfile content is as follows:

FROM bitnami/mysql:8.2.0-debian-11-r2

ENV TZ Asia/Muscat

COPY init_script.sh /docker-entrypoint-initdb.d/

The init_script sh file is shown below:

#!/bin/sh

mysql -u root -p"$MYSQL_ROOT_PASSWORD" <<EOF
CREATE DATABASE IF NOT EXISTS gs_keycloak;
CREATE USER keycloak IDENTIFIED BY 'keycloakdevpassword';
GRANT CREATE ROUTINE, ALTER ROUTINE, INDEX, DROP, REFERENCES, CREATE, ALTER, INSERT, SELECT, DELETE, UPDATE ON gs_keycloak.* TO keycloak WITH GRANT OPTION;

CREATE DATABASE IF NOT EXISTS gs;
CREATE USER gs IDENTIFIED BY 'fW7j272kVGwF';
GRANT CREATE ROUTINE, ALTER ROUTINE, INDEX, DROP, REFERENCES, CREATE, ALTER, INSERT, SELECT, DELETE, UPDATE ON gs.* TO gs1 WITH GRANT OPTION;
EOF

The directory for the mysql is as follows:

The mysql image is build successfully as shown below:

However when i run docker compose up command from the docker-compose file below:

      version: "3"
        
        volumes:
    
      mysql_data: #creates mount point on docker for mysql
    driver: local
  log_data: #creates mount point on docker for logs
    driver: local

    services:
      keycloak:
        image: keycloak-demo 
        command: start-dev
        container_name: keycloak-demo-container
        environment:
          DB_VENDOR: MYSQL
          DB_ADDR: mysql
          DB_DATABASE: gs1_keycloak
          DB_USER: keycloak
          DB_PASSWORD: root
          KEYCLOAK_USER: admin
          KEYCLOAK_PASSWORD: root
    
        ports:
          - "9090:8080"
        depends_on:
          - mysqldemo
        networks:
          network_demo_keyck:
    
      mysqldemo:
        image: keycloakdbs
        container_name: demo-mysql
        environment:
          DB_GS1_PWD: root
          DB_KEYCLOAK_PWD: root
          MYSQL_ROOT_PASSWORD: root
    
        ports:
          - "5432:5432" 
        networks:
          network_demo_keyck:
        volumes:
          - mysql_data:/var/lib/mysql
    
    networks:
      network_demo_keyck:

The following exception is thrown:

Please find below all logs mysql with exception:

   024-06-11 16:27:48 mysql 16:27:48.68 INFO  ==> 
2024-06-11 16:27:48 mysql 16:27:48.68 INFO  ==> Welcome to the Bitnami mysql container
2024-06-11 16:27:48 mysql 16:27:48.68 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
2024-06-11 16:27:48 mysql 16:27:48.68 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
2024-06-11 16:27:48 mysql 16:27:48.68 INFO  ==> 
2024-06-11 16:27:48 mysql 16:27:48.68 INFO  ==> ** Starting MySQL setup **
2024-06-11 16:27:48 mysql 16:27:48.69 INFO  ==> Validating settings in MYSQL_*/MARIADB_* env vars
2024-06-11 16:27:48 mysql 16:27:48.70 INFO  ==> Initializing mysql database
2024-06-11 16:27:48 mysql 16:27:48.70 INFO  ==> Updating 'my.cnf' with custom configuration
2024-06-11 16:27:48 mysql 16:27:48.71 INFO  ==> Setting slow_query_log option
2024-06-11 16:27:48 mysql 16:27:48.73 INFO  ==> Setting long_query_time option
2024-06-11 16:27:48 mysql 16:27:48.74 INFO  ==> Installing database
2024-06-11 16:28:00 mysql 16:28:00.16 INFO  ==> Starting mysql in background
2024-06-11 16:28:02 mysql 16:28:02.18 INFO  ==> Configuring authentication
2024-06-11 16:28:02 mysql: [Warning] Using a password on the command line interface can be insecure.
2024-06-11 16:28:02 mysql 16:28:02.31 INFO  ==> Running mysql_upgrade
2024-06-11 16:28:02 mysql 16:28:02.31 INFO  ==> Stopping mysql
2024-06-11 16:28:04 mysql 16:28:04.33 INFO  ==> Starting mysql in background
2024-06-11 16:28:22 mysql 16:28:22.36 INFO  ==> Loading user's custom files from /docker-entrypoint-initdb.d
2024-06-11 16:28:22 /opt/bitnami/scripts/libmysql.sh: /docker-entrypoint-initdb.d/init_script.sh: /bin/sh^M: bad interpreter: No such file or directory
2024-06-11 16:28:22 mysql 16:28:22.37 ERROR ==> Failed executing /docker-entrypoint-initdb.d/init_script.sh
2024-06-11 16:28:22 mysql 16:28:22.37 INFO  ==> Stopping mysql
2024-06-11 16:27:48 2024-06-11T12:27:48.761256Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2024-06-11 16:27:48 2024-06-11T12:27:48.762652Z 0 [System] [MY-013169] [Server] /opt/bitnami/mysql/bin/mysqld (mysqld 8.2.0) initializing of server in progress as process 43
2024-06-11 16:27:48 2024-06-11T12:27:48.780706Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-06-11 16:27:50 2024-06-11T12:27:50.121820Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-06-11 16:27:53 2024-06-11T12:27:53.229848Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2024-06-11 16:28:00 2024-06-11T12:28:00.079661Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
2024-06-11 16:28:00 2024-06-11T12:28:00.171876Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2024-06-11 16:28:00 2024-06-11T12:28:00.347076Z 0 [Warning] [MY-011068] [Server] The syntax 'skip_slave_start' is deprecated and will be removed in a future release. Please use skip_replica_start instead.
2024-06-11 16:28:00 2024-06-11T12:28:00.347145Z 0 [System] [MY-010116] [Server] /opt/bitnami/mysql/bin/mysqld (mysqld 8.2.0) starting as process 91
2024-06-11 16:28:00 2024-06-11T12:28:00.359775Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-06-11 16:28:00 2024-06-11T12:28:00.581587Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-06-11 16:28:00 2024-06-11T12:28:00.868614Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2024-06-11 16:28:00 2024-06-11T12:28:00.868663Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2024-06-11 16:28:00 2024-06-11T12:28:00.900815Z 0 [System] [MY-010931] [Server] /opt/bitnami/mysql/bin/mysqld: ready for connections. Version: '8.2.0'  socket: '/opt/bitnami/mysql/tmp/mysql.sock'  port: 3306  Source distribution.
2024-06-11 16:28:00 2024-06-11T12:28:00.900899Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2024-06-11 16:28:02 2024-06-11T12:28:02.321619Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.2.0).
2024-06-11 16:28:03 2024-06-11T12:28:03.386724Z 0 [System] [MY-010910] [Server] /opt/bitnami/mysql/bin/mysqld: Shutdown complete (mysqld 8.2.0)  Source distribution.
2024-06-11 16:28:03 2024-06-11T12:28:03.387438Z 0 [System] [MY-015016] [Server] MySQL Server - end.
2024-06-11 16:28:04 2024-06-11T12:28:04.340059Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2024-06-11 16:28:04 2024-06-11T12:28:04.510012Z 0 [Warning] [MY-011068] [Server] The syntax 'skip_slave_start' is deprecated and will be removed in a future release. Please use skip_replica_start instead.
2024-06-11 16:28:04 2024-06-11T12:28:04.510081Z 0 [System] [MY-010116] [Server] /opt/bitnami/mysql/bin/mysqld (mysqld 8.2.0) starting as process 189
2024-06-11 16:28:04 2024-06-11T12:28:04.516014Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-06-11 16:28:04 2024-06-11T12:28:04.713135Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-06-11 16:28:04 2024-06-11T12:28:04.829443Z 4 [System] [MY-013381] [Server] Server upgrade from '80200' to '80200' started.
2024-06-11 16:28:21 2024-06-11T12:28:21.061751Z 4 [System] [MY-013381] [Server] Server upgrade from '80200' to '80200' completed.
2024-06-11 16:28:21 2024-06-11T12:28:21.237557Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2024-06-11 16:28:21 2024-06-11T12:28:21.237602Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2024-06-11 16:28:21 2024-06-11T12:28:21.253989Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2024-06-11 16:28:21 2024-06-11T12:28:21.254039Z 0 [System] [MY-010931] [Server] /opt/bitnami/mysql/bin/mysqld: ready for connections. Version: '8.2.0'  socket: '/opt/bitnami/mysql/tmp/mysql.sock'  port: 3306  Source distribution.
2024-06-11 16:28:22 2024-06-11T12:28:22.382456Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.2.0).
2024-06-11 16:28:27 2024-06-11T12:28:27.622590Z 0 [System] [MY-010910] [Server] /opt/bitnami/mysql/bin/mysqld: Shutdown complete (mysqld 8.2.0)  Source distribution.
2024-06-11 16:28:27 2024-06-11T12:28:27.623816Z 0 [System] [MY-015016] [Server] MySQL Server - end.

Can anyone please advice what I am doing wrong? Thanks

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật