Low Orbit Flux Logo 2 D

Docker Interview Questions

Docker Interview Questions

What is Docker?

Docker is a platform for containerization. It allows you to bundle up your application into an isolated environment that includes all dependencies. Since everything is bundled together it should run the same everywhere. If someone says “It works on my machine.”, it should work everywhere.

What is containerization?

A container provides an isolated environment in which to run an application. Everything needed to run the application would be bundled together into the same container. This can then be distributed and run on other systems without having to worry about dependancies.

Containerization can be thought of almost like virtualization except a that it takes things a step further. A container can almost be thought of as a lightweight virtual machine. Unlike virtual machines, you wouldn’t install an OS on a container. A container shares the OS with other containers on the same system. It provides an isolated environment that looks like a completely separate system. Resources can be allocated on a container by container basis. Containers can also be thought of as a way of grouping and isolating processes.

What is virtualization?

Virtualization is abstraction of the hardware layer. A virtual machine simulates actual hardware with software. An entire OS is installed on a virtual machine creating an isolated environment. Virtualization allows for splitting up a single physical system into many virtual systems. Virtual machines are easier to provision than physical machines. It is also easier to allocate resources without wasting anything.

What is Hypervisor?

A hypervisor is a piece of software used for creating and running virtual machines. A hypervisor is responsible for allocating resources to virtual machines. A type 1 hypervisor runs directly on a physical machine and is the only layer sitting between the hardware and the guest operating systems. A type 2 hypervisor runs on top of another operating system. It is a layer that sits between the host OS and the guest OSes.

What is the difference between virtualization and containerization?

Virtualization involves creating virtual machines. These each have an entire copy of the OS. Containers are more light weight. They still create an isolated environment but they share the OS with other containers.

What is a Docker Container?

A Docker container is a runnable instance of a container. (See the definition of containers above.)

What are Docker Images?

A Docker image can be thought of as a blueprint. It is the used to create a container. Multiple containers can be created from a single image. An image can’t be run. Only the containers created from the image are run. When a container is changed it will not effect the original image.

What is a Dockerfile?

A Dockerfile is a set of instructions for building a Docker image. It specifies what base image to use, what packages to install, and what parameters to use when building an image. It is similar to a blueprint. You could think of it as a blueprint for an image. Since images are like blueprints for containers…. you could say that a Dockerfile is a blueprint of a blueprint.

What is Docker Hub?

Docker Hub is a Docker registry. It is a place to download images. This particular registry is run by Docker Inc. This is where you would download your images by default.

What is Docker Swarm?

Swarm is a builtin clustering technology for Docker. A Docker swarm is a group of virtual machines or physical machines that are configured to work as a cluster. Swarm helps with orchestration, load balancing, scaling, and more. You can easily define applications composed of many containers spanning multiple physical or virtual machines.

What is Docker Compose?

Docker compose is a tool that helps you setup all of the services in an application. It helps you configure Docker applications spanning multiple containers. Everything is defined in a YAML file and a single command is used to start everything up.

What is Kubernetes?

Kubernetes is a platform for managing containers. It is a container orchestration system. It provides support For deploying, scaling, automating, and managing clusters of containers.

What is the lifecycle of a Docker Container?

First a container is created or run. From there it can optionally be stopped and started. It can also optionally be paused or unpaused. It can also be restarted. Instead of stopping a container can be killed. Finally a container can be destroyed (removed).

docker start   smelly-hippo             # start
docker stop    smelly-hippo             # stop
docker stop    smelly-hippo funny-frog  # stop mutliple
docker restart smelly-hippo             # restart container
docker pause   smelly-hippo             # pauses a running container, freeze in place
docker unpause smelly-hippo             # unpause a container
docker wait    smelly-hippo             # blocks until running container stops
docker kill    smelly-hippo             # sends SIGKILL, faster than stop
docker rm      smelly-hippo             # remove
docker rm      smelly-hippo container5  # remove multiple
docker rm -f   smelly-hippo             # force remove

NOTE - You can create a container without running it. If you do this you will need to start the container. If you directly run a container, this will create and start the container all in one shot.

What is Docker Machine?

Docker Machine is a tool for managing and provisioning hosts that run Docker. It makes it easy to spin up a VM to run your Docker containers on.

How do you get the number of containers running, paused and stopped?

Just run “docker info”. This will tell you all of this and much more.

How do you see running containers?

Use “docker ps”.

How do you see both running and stopped containers?

Use “docker ps -a”.

Docker Interview Questions - What To Expect

You could expect more questions than this. There are all sorts of other Docker related things someone could ask. Not to mention chances are your interview will be about more than just Docker. There will likely be lots of other related technologies mixed in. It all depends on the type of interview. Are you going to be a developer? A sysadmin? Or potentially a devOps engineer or data engineer. Either way, this should give you a good start. If you are looking for more info just checkout our Docker Tutorial and Docker Cheat Sheet.

If you are looking for more Docker interview questions you might check out these sites: