Docker Interview Questions and Answers
Question - 81 : - Can you use a container, edit it, and update it? Also, how do you make it a new and store it on the local system?
Answer - 81 : -
Of course, you can use a container, edit it and update it. This sounds complicated but its actually just one command.
$ docker commit
Question - 82 : - How to start, stop and kill a container?
Answer - 82 : -
The following command is used to start a docker container:
$ docker start
and the following for stopping a running container:
$ docker stop
kill a container with the following command:
$ docker kill
Question - 83 : - How do you list all the running containers?
Answer - 83 : -
The following command lists down all the running containers:
$ docker ps
Question - 84 : - How do you create a docker container from an image?
Answer - 84 : -
Pull an image from docker repository with the above command and run it to create a container. Use the following command:
$ docker run -it -d
Most probably the next question would be, what does the ‘-d’ flag mean in the command?
-d means the container needs to start in the detached mode. Explain a little about the detach mode. Have a look at this blog to get a better understanding of different docker commands.
Question - 85 : - How far do Docker containers scale? Are there any requirements for the same?
Answer - 85 : -
Large web deployments like Google and Twitter and platform providers such as Heroku and dotCloud, all run on container technology. Containers can be scaled to hundreds of thousands or even millions of them running in parallel. Talking about requirements, containers require the memory and the OS at all the times and a way to use this memory efficiently when scaled.
Question - 86 : - What platforms does docker run on?
Answer - 86 : -
This is a very straightforward question but can get tricky. Do some company research before going for the interview and find out how the company is using Docker. Make sure you mention the platform company is using in this answer.
Docker runs on various Linux administration:
- Ubuntu 12.04, 13.04 et al
- Fedora 19/20+
- RHEL 6.5+
- CentOS 6+
- Gentoo
- ArchLinux
- openSUSE 12.3+
- CRUX 3.0+
It can also be used in production with Cloud platforms with the following services:
- Amazon EC2
- Amazon ECS
- Google Compute Engine
- Microsoft Azure
- Rackspace
Question - 87 : - Is there a way to identify the status of a Docker container?
Answer - 87 : -
There are six possible states a container can be at any given point – Created, Running, Paused, Restarting, Exited, Dead.
Use the following command to check for docker state at any given point:
$ docker ps
The above command lists down only running containers by default. To look for all containers, use the following command:
$ docker ps -a
Question - 88 : - Can you remove a paused container from Docker?
Answer - 88 : -
The answer is no. You cannot remove a paused container. The container has to be in the stopped state before it can be removed.
Question - 89 : - Will cloud overtake the use of Containerization?
Answer - 89 : -
Docker containers are gaining popularity but at the same time, Cloud services are giving a good fight. In my personal opinion, Docker will never be replaced by Cloud. Using cloud services with containerization will definitely hype the game. Organizations need to take their requirements and dependencies into consideration into the picture and decide what’s best for them. Most of the companies have integrated Docker with the cloud. This way they can make the best out of both the technologies.
Question - 90 : - How many containers can run per host?
Answer - 90 : -
There can be as many containers as you wish per host. Docker does not put any restrictions on it. But you need to consider every container needs storage space, CPU and memory which the hardware needs to support. You also need to consider the application size. Containers are considered to be lightweight but very dependant on the host OS.