Wednesday, June 10, 2020

Docker Interview questions

Hi Friends,

In this post , I'm sharing few questions-answers asked on Docker knowledge.



Question 1:

What is Portainer? What are it's uses?


Answer:

Portainer is an open source management UI for Docker including Docker swarm environment.

Portainer makes it easier for managing docker images, containers, networks and volumes from the web-based portainer dashboard.

Portainer consists of a single container that can run on any Docker engine.



Question 2:

What is docker and how does it work?

Answer:

Docker is a set of Platform as a Service  products that uses OS level virtualization to deliver softwares in packages called containers.

Docker resolves any compatibility issue that might occur in the versions of multiple services with the OS version.

With Docker , we are able to run each component /service in separate container with all it's dependencies and libraries and all on the same VM and OS.



Question 3:

What is container?

Answer:

Containers are completely isolated environments. They can have their own processes for services, their own network interfaces except that they all share the OS kernel.

Containers are not new with Docker. Containers have existed for about more than 10 years now and there are different types of containers : LX c , LX d etc.

Docker uses LX c types of containers.   

Setting up these container environment is very hard as they are very low level and that is where docker offers a high level tool with several powerful functionalities making it really easy for end-users.



Question 4:

List some useful docker commands with their purpose.

Answer:

docker run <imagename> :
  • docker run command is used to run a container from the image. e.g. : running the docker run nginx will run an instance of nginx application from the docker host if it already exists. If the image is not present on the docker host, then it will go out to docker hub and pull the image down. But this is only done for the first time. For the subsequent executions , the same image will be reused.

docker ps:
  • docker ps command lists all running containers and some basic information about them such as container ID, the name of the image we used to run container, the current status and name of the container.

docker ps -a:
  • It shows all running as well as previously stopped or exited containers.

docker stop <container name>
  • This command is used to stop the container and we need to provide either the container ID or container name.

docker rm <container name>
  • This command is used to remove any existed container permanently. Note: If this command prints the name back, we are good.

docker images:
  • This command prints a list of available images and their sizes.

docker rmi <imagename>
  • This command is used to remove any image that we are not supposed to use anymore.

docker pull <image name>
  • This command is used when we only want to pull the image and not to run it.

docker --version:
  • This command is used to get the currently installed version of docker.

docker exec:
  • This command is used to access the running container.


Question 5:

What is the difference between docker kill and docker stop?

Answer:

docker kill command kills the container by stopping its execution immediately.
While the docker stop command gives the container time to shutdown gracefully, in situations when it is taking too much time for getting the container to stop. 




That's all for this post.
Thanks for reading!!

No comments:

Post a Comment

CAP Theorem and external configuration in microservices

 Hi friends, In this post, I will explain about CAP Theorem and setting external configurations in microservices. Question 1: What is CAP Th...