Sign in to unlock

Get unlimited access to all questions and answers

checked

Get lifetime access

checked

Track progress

checked

Save time

55 Docker interview questions and answers for software engineers

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Here is a list of coding interview questions on Docker to help you get ready for your next data structures interview in 2021.

  • 1.

    What is Docker?

    Answer:

    • Docker is a containerization platform which packages your application and all its dependencies together in the form of containers so as to ensure that your application works seamlessly in any environment be it development or test or production.
    • Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries etc. anything that can be installed on a server.
    • This guarantees that the software will always run the same, regardless of its environment.
    Source: edureka.co   
  • 2.

    What is the difference between a Docker image and a container?

    Answer:

    An instance of an image is called a container. You have an image, which is a set of layers. If you start this image, you have a running container of this image. You can have many running containers of the same image.

    You can see all your images with docker images whereas you can see your running containers with docker ps (and you can see all containers with docker ps -a).

    So a running instance of an image is a container.

    Source: stackoverflow.com   
  • 3.

    What is the difference between the COPY and ADD commands in a Dockerfile?

    Answer:

    Although ADD and COPY are functionally similar, generally speaking, COPY is preferred.

    That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /.

    Source: stackoverflow.com   
  • 4.

    What is Docker hub?

    Answer:

    Docker hub is a cloud-based registry service which allows you to link to code repositories, build your images and test them, stores manually pushed images, and links to Docker cloud so you can deploy images to your hosts. It provides a centralized resource for container image discovery, distribution and change management, user and team collaboration, and workflow automation throughout the development pipeline.

    Source: edureka.co   
  • 5.

    What are the various states that a Docker container can be in at any given point in time?

    Answer:

    There are four states that a Docker container can be in, at any given point in time. Those states are as given as follows:

    • Running
    • Paused
    • Restarting
    • Exited
    Source: mindmajix.com   
  • 6.

    When would you use ‘docker kill’ or ‘docker rm -f’?

    Answer:

    If you must stop the container really quickly… (someone pushed something to production on Friday evening?… ;) )

    Source: rafalgolarz.com   
  • 7.

    Is there a way to identify the status of a Docker container?

    Answer:

    We can identify the status of a Docker container by running the command

    docker ps –a

    which will in turn list down all the available docker containers with its corresponding statuses on the host. From there we can easily identify the container of interest to check its status correspondingly.

    Source: mindmajix.com   
  • 8.

    What is the difference between ‘docker run’ and ‘docker create’?

    Answer:

    The primary difference is that using ‘docker create’ creates a container in a stopped state.

    Bonus point: You can use ‘docker create’ and store an outputed container ID for later use. The best way to do it is to use ‘docker run’ with --cidfile FILE_NAME as running it again won’t allow to overwrite the file. A good practice is to keep well ogranised directory structure: /containers/web/server1/ws.cid containers/web/server3/ws.cid

    Source: rafalgolarz.com   
  • 9.

    What is the difference between CMD and ENTRYPOINT in a Dockerfile?

    Answer:

    Both CMD and ENTRYPOINT instructions define what command gets executed when running a container. There are few rules that describe their co-operation.

    1. Dockerfile should specify at least one of CMD or ENTRYPOINT commands.
    2. ENTRYPOINT should be defined when using the container as an executable.
    3. CMD should be used as a way of defining default arguments for an ENTRYPOINT command or for executing an ad-hoc command in a container.
    4. CMD will be overridden when running the container with alternative argumen
    Source: stackoverflow.com   
  • 10.

    What’s the difference between a repository and a registry?

    Answer:

    • Docker registry is a service for hosting and distributing images (the default one is the Docker Hub).
    • Docker repository is a collection of related Docker images (the same name but with different tags).
    Source: rafalgolarz.com   
  • 11.

    Do I lose my data when the Docker container exits?

    Answer:

    There is no loss of data when any of your Docker containers exits as any of the data that your application writes to the disk in order to preserve it. This will be done until the container is explicitly deleted. The file system for the Docker container persists even after the Docker container is halted.

    Source: mindmajix.com   
  • 12.

    Can you remove (‘docker rm’) a container that is paused?

    Answer:

    No, to remove a container it must be stopped first.

    Source: rafalgolarz.com   
  • 13.

    What is Build Cache in Docker?

    Answer:

    When we build an Image, Docker will process each line in Dockerfile. It will execute the commands on each line in the order that is mentioned in the file. But at each line, before running any command, Docker will check if there is already an existing image in its cache that can be reused rather than creating a new image.

    Source: mindmajix.com   
  • 14.

    How to build envrionment-agnostic systems with Docker?

    Answer:

    There are three main features helping to achieve that:

    • Volumes
    • Environment variable injection
    • Read-only file systems
    Source: rafalgolarz.com   
  • 15.

    How to link containers?

    Answer:

    The simplest way is to use network port mapping. There’s also the - -link flag which is deprecated.

    Source: rafalgolarz.com   
One tip that got me hired by Google, Microsoft, and Stripe

I've worked for Microsoft, Google, Stripe, and received offers from many other companies. One thing I learned when I was interviewing myself is that standard interview tips are woefully inadequate.

Reverse Tech Interview: Questions to Stump an Interviewer

Few people want to get into an uncomfortable environment or an unprofitable company with no prospects. If you’re wondering how to get a real feel for a company during an interview, you’re welcome. I’ll give a list of questions that interviewers don’t usually expect...

How to become a programmer, move to the US, and get a dream job

Are you curious about what you need to do to earn more than $15.000 a month, drive a Tesla, live in sunny California, and work at Google, Apple, Facebook, or Amazon?

11 Reactive Systems interview questions and answers for software engineers

Reactive systems are an architectural style that allows multiple individual applications to blend into one unit, reacting to their environment, while staying aware of each other. Here is a list of coding interview questions on Reactive Systems to help you get ready for your next data struc...

. Reactive Systems
34 Microservices interview questions and answers for software engineers

Microservice architecture – a variant of the service-oriented architecture structural style – arranges an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained and the protocols are lightweight. Here is a list of coding intervie...

. Microservices
7 Layering & Middleware interview questions for developers

Middleware in the context of distributed applications is software that provides services beyond those provided by the operating system to enable the various components of a distributed system to communicate and manage data. Middleware supports and simplifies complex distributed application...

. Layering & Middleware
55 Docker interview questions and answers for software engineers

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Here is a list of coding interview questions on Docker to help you get ready for your next data structures interview in 2021.

. Docker
23 Databases interview questions and answers for software engineers

A database is an organized collection of data, generally stored and accessed electronically from a computer system. Where databases are more complex they are often developed using formal design and modeling techniques. Here is a list of coding interview questions on Databases to help you g...

. Databases
21 Concurrency interview questions and answers for software engineers

In computer science, concurrency is the ability of different parts or units of a program, algorithm, or problem to be executed out-of-order or in partial order, without affecting the final outcome. Here is a list of coding interview questions on Concurrency to help you get ready for your n...

. Concurrency
13 CAP Theorem interview questions and answers for software engineers

In theoretical computer science, the CAP theorem, also named Brewer's theorem after computer scientist Eric Brewer, states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees: Consistency: Every read receives the ...

. CAP Theorem
Load more posts

Features

folder icon

Access all answers

Get the inside track on what to expect in your next tech interview. We offer you a collection of high quality technical interview questions to help you prepare for your next coding interview.

graph icon

Track progress

A smart interface helps you track your progress and focus on the topics you need. You can search through questions or sort them by difficulty or type.

clock icon

Save time

Save tens of hours searching for information on hundreds of low-quality sites designed to drive traffic and make money from advertising.

Land a six-figure job at one of the top companies.

amazon logo facebook logo google logo microsoft logo uber logo
Prepare for a technical interview

Get hired with our
tech interview questions & answers