concept Entrypoint in category hyperledger

This is an excerpt from Manning's book Programming Hyperledger Fabric: Creating Permissioned Blockchains.
9.3.6.
Cmdvs.EntrypointWhat does a container do when it is started? It starts executing the
CmdorEntrypointdefined in the image (refer Listing 9.9) unless those values are overriden by the user. We can override theCmdhardcoded in the image by specifying an argument after the image name when starting the container as done in Listing 9.4. In Listing 9.4 it did not make any difference since the hardcodedCmdin the image is alsoorderer. There is another field calledEntrypointwhich does the same thing asCmd. It can also be overriden but requires the use of the--entrypointflag. E.g.,$ docker run --entrypoint orderer hyperledger/fabric-orderer:2.0.1Note that in this case the override comes before the image name (in case of
cmdthe override came after the image name e.g., refer Listing 9.4). If there are two fields which do the same thing then what happens if both are specified? When both anEntrypointandCmdare specified, theCmdstring(s) are appended to theEntrypointin order to generate the container’s command string. So in a sense theEntrypointtriumphs over theCmd. You can use a combination ofEntrypointandCmdwhen you intend the command to execute when container is started to be fixed but the command requires some arguments that will be provided by user when container is started. [18]The
CmdorEntrypointis typically supposed to be a command that will run forever such as starting a server that will keep listening for requests forever. If theCmdorEntrypointexits then so does the Docker container. This puts the container in exited or terminated state. It still exists but is no longer running. You can check this by runningdocker ps -a -f name=<container-name>which will show the container as exited. If the container is run with the--rmflag then it will get auto-deleted when it exits. In that case the container name will not show up if you rundocker ps -acommand.