Docker Interview Questions and Answers
Ques 16. How can you limit the resources (CPU, memory) a container can use?
Docker allows resource constraints to be set using the `--cpu` and `--memory` options when running a container.
Example:
docker run --cpu=0.5 --memory=512m my_image
Ques 17. What is the purpose of Docker Swarm?
Docker Swarm is a native clustering and orchestration solution for Docker. It allows you to create and manage a swarm of Docker nodes, making it easy to scale and manage applications.
Ques 18. How do you remove a Docker image?
You can use the `docker rmi` command followed by the image ID or name to remove a Docker image.
Example:
docker rmi image_name
Ques 19. What is the purpose of Docker Compose volumes?
Docker Compose volumes allow data to persist between container restarts. They are specified in the `docker-compose.yml` file and are used for sharing data between services.
Example:
volumes:
- data_volume:/app/data
Ques 20. Explain the concept of Docker Swarm Services.
Docker Swarm Services define how containers should behave in production. They enable scaling, rolling updates, and load balancing across a swarm.
Example:
docker service create --replicas 3 my_image
Most helpful rated by users: