concept Entrypoint in category hyperledger

appears as: Entrypoint, Entrypoint
Programming Hyperledger Fabric: Creating Permissioned Blockchains

This is an excerpt from Manning's book Programming Hyperledger Fabric: Creating Permissioned Blockchains.

9.3.6. Cmd vs. Entrypoint

What does a container do when it is started? It starts executing the Cmd or Entrypoint defined in the image (refer Listing 9.9) unless those values are overriden by the user. We can override the Cmd hardcoded 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 hardcoded Cmd in the image is also orderer. There is another field called Entrypoint which does the same thing as Cmd. It can also be overriden but requires the use of the --entrypoint flag. E.g.,

$ docker run --entrypoint orderer hyperledger/fabric-orderer:2.0.1

Note that in this case the override comes before the image name (in case of cmd the 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 an Entrypoint and Cmd are specified, the Cmd string(s) are appended to the Entrypoint in order to generate the container’s command string. So in a sense the Entrypoint triumphs over the Cmd. You can use a combination of Entrypoint and Cmd when 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 Cmd or Entrypoint is typically supposed to be a command that will run forever such as starting a server that will keep listening for requests forever. If the Cmd or Entrypoint exits 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 running docker ps -a -f name=<container-name> which will show the container as exited. If the container is run with the --rm flag then it will get auto-deleted when it exits. In that case the container name will not show up if you run docker ps -a command.