Docker Interview Questions
1. What is the difference between CMD and ENTRYPOINT in a Dockerfile?
Ans: CMD in Dockerfile Instruction is used to execute a command in a Running container, There should be one CMD in a Dockerfile.
ENTRYPOINT in Dockerfile Instruction is used you to configure a container that you can run as an executable.
2. Tell us about the steps for the Docker container life cycle.
Here are the steps with relevant commands:
- Create container: docker create — name <container-name> <image-name>
- Run docker container: docker run -it -d — name <container-name> <image-name> bash
- Pause container: docker pause <container-id/name>
- Unpause container: docker unpause <container-id/name>
- Start container: docker start <container-id/name>
- Stop container: docker stop <container-id/name>
- Restart container: docker restart <container-id/name>
- Kill container: docker kill <container-id/name>
- Destroy container: docker rm <container-id/name>