How to execute shell scripts in a container when docker starts a container

my goal is to execute the shell script in the container to start some services when starting the container, but after executing

    docker run -it --privileged=true newtest /bin/bash -c "sh ./init.sh" 
After the

command, the container is the state of the Exited.

CONTAINER ID        IMAGE               COMMAND                  CREATED                  STATUS                       PORTS                                                    NAMES
f14863acb5d7        newtest             "/bin/bash -c init.sh"   Less than a second ago   Exited (127) 4 seconds ago                                                            serene_wing
Mar.19,2021

process No.1 in the container cannot be stopped if needed. Your No.1 process is init.sh, of course, it will stand up after it has been executed. You write an infinite loop in init.sh and you get the effect you want.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48c3b-44035.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48c3b-44035.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?