CMD in Dockerfile

Defines the program that will be run within the container when it starts.

For nginx image is the:

CMD ["nginx"] # nginx command
For the mysql image is the:
CMD ["mysqld"] # mysql command
If this process finishes or crashes - the container exits as well.
There are different ways to specify the CMD: To override this command for a running container pass the option [COMMAND] to the docker executable:
docker run ubuntu [COMMAND]
for example:
docker run ubuntu sleep 10