Basic Questions/Answers for Docker.
Question 1: What is Docker?
Answer: Docker is an open-source containerization platform. It used to automate deployment of any application, using lightweight portal container.
Question 2: What is Container?
Answer: Container is deployed bundle of an application that contain all necessary dependencies and configuration files.
All the elements shared with based OS kernel.
Question 3: What is dangling docker image?
Answer: Dangling images are untagged Docker images that are not associated with any container. They are created when they are overwritten with a new image with the same name and tag.
Question 4: What is Container lifecycle?
Answer: Container Following is the most common.
- Create container.
- Run container.
- Pause Container.
- Stop Container.
- Start Container.
- Restart Container.
- Kill Container.
- Destroy container.
Question 5: Mostly used Docker Commands.
Answer: Following are the commonly used command.
- To run a container.
docker run -it -d -p <hostport:container-port> <image-name>
Example: docker run -it -d -p 8080:80 nginx - To list all running containers.
docker ps
- To list all container including exit one.
docker ps -a
- To stop container.
docker stop <container-name or container-id>
example: docker stop nginx - To remove container.
docker rm <container-name>
example: docker rm nginx - To build a Docker image.
docker build -t <image-name:tag>
example: docker build -t nginx:v1 - To list Docker images
docker image ls or docker images
- To remove Docker images
docker rmi <image-name/or image-id>
docker rmi nginx:v1 - To remove unused docker images
docker image prune -a