How does docker execute shell scripts inside a container when it starts a container

  docker, question

My goal is to start some services by executing the shell script in the container when starting the container, but I did

docker run -it --privileged=true newtest /bin/bash -c 'sh ./'

After the command, the container is in the existing state.

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

Process No.1 in the container needs to be stopped. Your No.1 process is, and it will certainly survive after execution. If you write an infinite loop in, you will achieve the desired effect.