Docker Interview Questions and Answers

Docker Interview Questions and Answers

Last updated on 25th Sep 2020, Blog, Interview Question

About author

Manikandan ( (Sr Technical Architect ) )

High level Domain Expert in TOP MNCs with 8+ Years of Experience. Also, Handled Around 36+ Projects and Shared his Knowledge by Writing these Blogs for us.

(5.0) | 16739 Ratings 827

Docker is a helpful tool for packing, shipping, and running applications within ‘containers’. Software engineers, Information Architects and DevOps engineers with Docker are in seriously high demand. As many big firms like Google, Amazon, and VMware have looked towards Docker as the go-to container technology, it is the right time to learn the tool and make a career out of it. If you wish to do so, below are the top Docker interview questions that you need to know. 

1. What is Docker?


Docker is an open-source container service designed to facilitate applications deployment inside the software containers. It will rely on Linux Kernel Features like namespaces and cgroups ensuring which resource isolation and application packaging along with its dependencies. Docker was licensed under Apache License 2.0 in the binary form and fully written in the Go programming language. It can support several operating systems like Linux, Cloud, Windows, and Mac OS and different platforms like ARM architecture and x86-64 windows platforms.

2. Why use Docker?


  • A user can quickly build, ship, and run its applications.
  • A single operating system kernel will run all containers.
  • Docker containers are more light-weight than the virtual machines.
  • A user will deploy Docker containers anywhere, on any physical and virtual machines and even on the cloud.

3. List the most used commands of Docker.


1. ps lists the running containers.

2. dockerd launches Docker Daemon.

3. build is used to build an image from a DockerFile.

4. create is used to create a new image from container’s changes.

5. pull is used to download a specific image or a repository.

6. run is used to run a container.

7. logs display the logs of a container.

8. rm removes one or more containers.

9.rmi removes one or more images.

10. stop is used to stop one or more containers.

11. kill is used to kill all running containers.

4. Does the data get lost, if the Docker container exits?


No. any data which application will write to disk can get well preserved in its container until we will explicitly delete the container and the file system will persist even after the container halts.

5. What is virtualization?


Virtualization is the process of creating a software-based, virtual version of something (compute storage, servers, application, etc.). These virtual versions or environments are created from a single physical hardware system. Virtualization lets you split one system into many different sections which act like separate, distinct individual systems. A software called Hypervisor makes this kind of splitting possible. The virtual environment created by the hypervisor is called Virtual Machine.

6. How is Docker advantageous over Hypervisors?


Docker is advantageous in following way

  • It is lightweight.
  • More efficient in terms of resources.
  • It uses very few resources and also the underlying host kernel rather than developing its hypervisor.

7. What is a Docker Container?


Docker containers include the application and all of its dependencies. It shares the kernel with other containers, running as isolated processes in user space on the host operating system. Docker containers are not tied to any specific infrastructure: they run 

on any computer, on any infrastructure, and in any cloud. Docker containers are basically runtime instances of Docker images.

8. How to create a Docker container?


A Docker Container will be created by running any specific Docker image.

Use the following command to create a container .

  • docker run -t -i command name

If to verify that whether the container has been created or whether that is running or not, use the following command as this command will list out all the running Docker containers on the host along with their status.

  • docker ps -a

9. What is Hypervisor?


A hypervisor is a software that makes virtualization possible. It is also called Virtual Machine Monitor. It divides the host system and allocates the resources to each divided virtual environment. You can basically have multiple OS on a single host system. There are two types of Hypervisors:

Type 1: It’s also called Native Hypervisor or Bare metal Hypervisor. It runs directly on the underlying host system. It has direct access to your host’s system hardware and hence does not require a base server operating system.

Type 2: This kind of hypervisor makes use of the underlying host operating system. It’s also called Hosted Hypervisor.

10. What are the components of Docker Architecture?


Docker Client (docker) – It will enable a user for Docker interaction. It will communicate with more than one Docker Daemon. It can use Docker API and can send commands ( docker run) to Docker Daemon ( dockerd ) which carries them out.

Docker Daemon ( dockerd ) – It will give a complete environment to execute and run applications. It consists of images, containers, volumes and is responsible for all container-related actions. It can pull and create the container images as what the client requests. A Daemon will communicate with other daemons for its service management.

Docker registry is a versioning, storage, and distribution system for Docker images. It allows Docker users to pull images locally, and push new images to the registry. Docker Hub is a public registry instance of Docker used by default while installing Docker Engine.

Docker Image is a lightweight, standalone, executable package of Docker stored in a Docker Registry. It can be used for creating a container. It will consist of everything required to run an application- code, a runtime, system libraries, system tools, environment variables, configuring files, and settings.

Docker Container– It is a standardized unit of software used for deploying a particular application or environment. It is launched by running an image. It can package up code and all of its dependencies therefore apps will run quickly and reliably from one computing environment to another.

Subscribe For Free Demo

Error: Contact form not found.

11. On what platforms does Docker run?


Docker will run on various platforms as follows:


  • Ubuntu 12.04, 13.04 et al
  • Fedora 19/20+
  • RHEL 6.5+
  • CentOS 6+
  • Gentoo
  • ArchLinux
  • openSUSE 12.3+
  • CRUX 3.0+

Microsoft Windows

  • Windows Server 2016
  • Windows 10


  • Amazon EC2
  • Google Compute Engine
  • Microsoft Azure
  • Rackspace

12. What is the purpose of Docker_Host?


It will contain container, images, and Docker daemon. It will offer a complete environment to execute and run applications.

13. What is Docker Engine?


Docker Engine is a Client-Server application which is installed on the host machine. It will allow us to develop, assemble, ship, and run applications anywhere. It can be available for Linux or Windows Server. Its major components are as follows:

1. Server is a long-running program which is called a Daemon process (docker )

2. REST API specifies interfaces which docker will use to communicate with Daemon and instruct it what to do.

3. CLI (Command Line Interface) – It will use the Docker REST API to manage and interact with the Daemon through its scripting commands.

14. What is the Lifecycle of Docker containers?


The Lifecycle of Docker Container with CLI is as following:

1. Create a Container.

2. Run the created Container.

3. Pause the processes running inside the Container.

4. Unpause the processes running inside the Container.

5. Start the Container, if it exists in a stopped state.

6. Stop the Container as well as the running processes.

7. Restart the Container as well as the running processes.

8. Kill the running Container.

9. Destroy the Container, only if it exists in a stopped state.

15. What is Kubernetes and Docker?


Docker is a platform and tool to build, distribute, and run Docker containers.

Kubernetes is a container orchestration system for Docker containers which is more extensive than Docker Swarm and will be meant to coordinate clusters of nodes at scale in production in an efficient manner.

16. When should I use Docker? When To Use Docker?


In following cases should I use Docker:

  • Use Docker as a version control system for the entire app’s operating system.
  • Use Docker when you want to distribute/collaborate on an app’s operating system with a team.
  • Use Docker to run code on laptop in the same environment as we have on your server (try the building tool).

17. What is the advantage of Docker?


The most important advantages to a Docker-based architecture is actually standardization. Docker will provide repeatable development, build, test, and production environments. Every team member can work on a production parity environment by Standardizing service infrastructure across the entire pipeline.

18. Why is Docker needed?


The Docker is required to ease the creation, deployment and the delivery of an application using the called Containers. A Docker Container has just the minimum set of operating systems, not a full operating system, a software required for the application to run and rely on the host Linux Kernel itself.

19. Is Kubernetes better than Docker?


Kubernetes and Docker aren’t an alternative to each other. Quite the contrary; Kubernetes will run without Docker and Docker will function without Kubernetes. Kubernetes will benefit greatly from Docker and vice versa. Docker is a standalone software which will be installed on any computer to run containerized applications.

20. What is the difference between Docker and Openshift?


The main difference between Docker and Openshift is that Docker as a project will focus on the runtime container only, whereas OpenShift as a system will include both the runtime container along the REST API, coordination, and web interfaces for deploying and manage individual containers. A cartridge has similarity to a docker image.

21. What are the disadvantages of Docker?


Following are disadvantages with Docker:

  • Containers will not run at bare-metal speeds.
  • Containers consume resources more efficiently than virtual machines but still it is subject to performance overhead due to overlay networking, interfacing between containers and the host system and so on.

22. What is the most popular use of Docker?


The most common technologies running in Docker are:

NGINX: Docker is mostly used for deploying and running HTTP servers.

Redis: This popular key-value store is a regular feature at the top of the list of container images.

Postgres: The open source relational database is steadily increasing in popularity.

23. Should I use Docker for development?


The development environment is similar to the production environment. We will deploy and it can “just work”. If it is a hard time to build something by build or compile, build it inside Docker.

24. Is Docker a VM?


In a virtual machine, valuable resources will be emulated for the guest OS and hypervisor, that will make it possible to run many instances of one or more operating systems in parallel on a single machine or host. Docker containers are executed with the Docker engine not with the hypervisor.

25. Why is Docker so popular?


Docker is popular because it has revolutionized development. Docker, and the containers it will make possible, has revolutionized the software industry and in five short years their popularity as a tool and platform has increased. The main reason is that containers will create vast economies of scale.

26. How do I download Docker?


Following way Docker can be downloaded:

1. Install Docker for Mac

2. run it

3. Double-click Docker.dmg for opening the installer, then drag Moby the whale to the Applications folder.

4. Double-click in the Applications folder to start Docker.

5. Click the whale ( ) to get Preferences and other options.

6. Select About Docker to verify that you have the latest version.

27. Do we need Docker?


Docker will shine compared to virtual machines when it will come to performance because containers will share the host kernel and will not emulate a full operating 

system. Docker does impose performance costs. If we are required to get the best possible performance out of the server, we may be required to avoid Docker.

28. What can you do with Docker?


We are just some of the use cases which will provide a consistent environment at low overhead with the enabling technology of Docker.

1. Simplifying Configuration.

2. Code Pipeline Management.

3. Developer Productivity.

4. App Isolation.

5. Server Consolidation.

6. Debugging Capabilities.

7. Multi-tenancy.

29. What are Docker images?


A Docker image is a file which consists of multiple layers, used for executing code in a Docker container. An image will be essentially built from the instructions for a complete and executable version of an application, which will rely on the host OS kernel.

30. Is Docker a Microservice?


Docker will Benefit for Microservices. Docker, as a containerization tool, will be often compared to virtual machines. Virtual machines are introduced to optimize the use of computing resources. We will run several VMs on a single server and deploy each application instance on a separate virtual machine.

Course Curriculum

Get Experts Curated Docker Training with Industry Trends Concepts

  • Instructor-led Sessions
  • Real-life Case Studies
  • Assignments
Explore Curriculum

31. How much does Docker cost?


If we are required to run Docker in production, however, the company will encourage users to sign up for a subscription package for an enterprise version of the platform. Docker will offer three enterprise editions of its software. Pricing which starts at $750 per node per year.

32.What is docker in AWS?


Docker is a software platform which will allow us to build, test, and deploy applications quickly. Running Docker on AWS will provide developers and admins a highly reliable, low-cost way for building, ship, and run distributed applications at any scale.

33. Is Kubernetes free?


Pure open source Kubernetes is free and it can be downloaded from its repository on GitHub. Administrators should build and deploy the Kubernetes release to a local system or cluster or to a system or cluster in a public cloud, such as AWS, Google Cloud Platform (GCP) or Microsoft Azure.

34. Difference between virtualization and containerization?


Containers will provide an isolated environment to run the application. The entire user space will be explicitly dedicated to the application. Any changes which are made inside the container will never be reflected on the host or even other containers running on the same host. Containers will be an abstraction of the application layer. Each container has a different application.

In virtualization, hypervisors will provide an entire virtual machine to the guest including Kernel. Virtual machines will be an abstraction of the hardware layer. Each VM is a physical machine.

35. Explain how you can clone a Git repository via Jenkins?


To clone a Git repository via Jenkins, we have to enter the email and username for Jenkins system. To do that we have to switch into the job directory and execute the “git config” command.

36. What is a Docker Container and its advantages?


Docker containers will include the application and all of its dependencies. It will share the kernel with other containers, running as isolated processes in user space on the host operating system. Docker containers will not require any specific infrastructure, they will run on any infrastructure, and in any cloud. Docker containers will be basically runtime instances of Docker images.

Following are major advantage of using Docker Container :

  • It will offer an efficient and easy initial set up.
  • It will describe the application lifecycle in detail.
  • Simple configuration and interacts with Docker Compose.
  • Documentation will provide every bit of information.

37. Explain Docker Architecture?


Docker Architecture will consist of a Docker Engine that is a client-server application:

  • A server which is a type of long-running program which is called a daemon process ( the docker command ).
  • A REST API which will specify interfaces that programs will use to talk the daemon and instruct it what to do.
  • A command-line interface (CLI) client (the docker command) The CLI will use the Docker REST API to control or interact with Docker daemon applications using the underlying API and CLI.

38. What is Docker Hub?


Docker hub is a cloud-based registry that will help us to link code repositories. It will allow us to build, test, store images in the Docker cloud. We can deploy the image to host with the help of the Docker hub.

39. What are the important features of Docker?


Following are the essential features of Docker:

  • Easy Modeling
  • version Control
  • Placement/Affinity
  • Application Agility
  • Developer Productivity
  • Operational Efficiencies

40. Suppose you have an application that has many dependent services. Will docker compose wait for the current container to be ready to move to the running of the next service?


The answer is yes. Docker compose always runs in the dependency order. These dependencies are specifications like depends_on, links, volumes_from, etc.

41. Tell us something about Docker Compose.


Docker Compose is a YAML file which will contain details about the service, network, and volumes to set up the Docker application. Therefore, we will use Docker compose for creating separate containers, host them and get them to communicate with other containers.

42. What is Docker Swarm?


Docker Swarm is native clustering for Docker. It will turn a pool of Docker hosts into a single, virtual Docker host. Docker Swarm will serve the standard Docker API, any tool which already communicates with a Docker daemon will use Swarm to transparently scale to multiple hosts.

43. If you wish to use a base image and make modifications or personalize it, how do you do that?


You pull an image from docker hub onto your local system

It’s one simple command to pull an image from docker hub:

  • $ docker pull <image_name>

44. Explain Registries


Two types of registry are

  • Public Registry
  • Private Registry

Docker’s public registry is called Docker hub, which will allow it to store images privately. In Docker hub, we will store millions of images.

45. What command should you run to see all running containers in Docker?


  • $docker ps

46. Write the command to stop the Docker Container.


  • $ sudo docker stop container name

47. What is the command to run the image as a container?


  • $ sudo docker run -i -t alpine /bin/bash

48. Explain Docker object labels.


Docker object labels is a method to apply metadata to docker objects which will include images, containers, volumes, network, swarm nodes, and services.

49. Write a Docker file to create and copy a directory and build it using python modules?


  • FROM python:2.7-slim
  • WORKDIR /app
  • COPY . /app
  • docker build –tag

50. Where the docker volumes are stored?


We required to navigate


Course Curriculum

Get Practical Oriented Docker Certification Course By Experts Trainers

Weekday / Weekend BatchesSee Batch Details

51. How do you run multiple copies of a Compose file on the same host?


Compose will use the project name which will allow us to create unique identifiers for all of a project’s containers and other resources. To run multiple copies of a project, set a custom project name using the -a command-line option or using COMPOSE_PROJECT_NAME environment variable.

52. Did Docker come up with the ‘container’ technology?


No, Docker did not come up with the container technology. Multiple other development tools offer containers similar to Docker.

53. How is Docker better than other tools that use containers, then?


Docker will utilise the cloud to run its container-related operations – which is not used by many other development tools. Docker will become much more flexible and adaptable

 to different scenarios using the cloud, which might come up during the development or shipment processes. This is the main reason to use Docker when compared to other container-based developer tools.

54. What is a Dockerfile?


A Dockerfile is a set of instructions. Developers provided Docker with such instructions therefore the program could do the job correctly, with those specific parameters in mind.

55. What are the three main types of Docker components?


The Client, the Host, and the Registry.

The client is the component which will issue “run” and “build” commands to the host. The host is where all of the containers and images will be created. They will be then sent to the registry, for execution.

56. Will you lose all of your work if you accidentally exit a container?


No, We won’t lose any information, data and other parameters if we accidentally exit the Docker container. The only way to lose progress would be to issue a specific command to delete the container – exiting it won’t do the files within any harm.

57. Can you use any other files for composing instead of the default YAML?


Yes, The more popular version to use than YAML is the good-old JSON.

58. What is ‘NameSpaces’ used for?


NameSpaces will isolate the Docker containers from other activities or tampering with them.

59. What is the single most important requirement for building a Docker container?


The most important requirement for building a container with Docker is the default image. This default image will vary depending on the code that we are using. To find out and access the default image, we should go to the Docker Hub and search for the specific domain that we required. After we find the image, all that’s left to do is deal with the documentation and that’s it – we can create a Docker container.

60. How does Docker manage ‘Dockerized nodes’?


A Dockerized node can be any machine which has Docker installed and running. Docker will manage both in-house and cloud-based nodes. Therefore, whether the node 

will exist in the area of the main computer running Docker or it is present on the cloud – it will not matter. Docker can manage it without a problem.

61. What are the main factors that dictate the number of containers you can run?


There is no defined limit of containers that we can run with Docker. The limitations may start due to hardware.

Two factors might limit the number of containers that we can run – the size of app and CPU strength. If application isn’t ginormous and we have a never-ending supply of CPU power, we could probably run a huge amount of Docker containers simultaneously.

62. How is Docker different from Hypervisor?


Hypervisor will require to have extensive hardware to function properly, while Docker will run on the actual operating system. This will allow Docker to be exceptionally fast and perform tasks in a fluid manner – something which Hypervisor tends to lack.

63. Can I use JSON instead of YAML for my compose file in Docker?


YES, We can very comfortably use JSON instead of the default YAML for Docker compose file. In order to use JSON file with compose, we required to specify the filename to use as the following:

  • docker-compose -f docker-compose.json up

64. Tell us how you have used Docker in your past position?


We could also explain the ease that this technology has brought in the automation of the development to production lifecycle management. We can also discuss any other integrations that we might have worked on with Docker like Puppet, Chef or even the most popular of all technologies – Jenkins.

65. How to stop and restart the Docker container?


The following command will be used to stop a certain Docker container with the container id as

  • docker stop CONTAINER_ID
  • The following command will be used to restart a certain Docker container with the container id as
  • docker restart CONTAINER_ID

66. How far do Docker containers scale?


The Web deployments such as Google, Twitter and best examples in the Platform Providers such as Heroku, dotCloud run on Docker that can scale from the ranges of hundreds of thousands to millions of containers running in parallel, provided the condition which the OS and the memory will not run out from the hosts which runs all these innumerable containers hosting your applications.

67. What changes are expected in your docker compose file while moving it to production?


These are the following changes you need make to your compose file before migrating your application to the production environment:

  • Remove volume bindings, so the code stays inside the container and cannot be changed from outside the container.
  • Binding to different ports on the host.
  • Specify a restart policy
  • Add extra services like log aggregator

68. What is the advantage of Docker over hypervisors?


Docker is lightweight and more efficient in resource uses because it will use the underlying host kernel rather than creating its hypervisor.

69. Is Container technology new?


No, container technology is not new. Different variations of containers technology ate out there in *NIX world for a long time. Solaris containers (aka Solaris Zones)-FreeBSD Jails-AIX Workload Partitions (aka WPARs)-Linux OpenVZ are examples.

70. How is Docker different from other container technologies?


Docker is a quite fresh project. It was created in the Era of Cloud, Therefore a lot of things are better than in other container technologies. Following are the features which are good in Docker:

  • Docker will run on any infrastructure, we can run docker on laptop, or can run it in the cloud.
  • Docker has a Container HUB which is a repository of containers that can download and use. We can even share containers with any applications.
  • Docker is quite well documented.
Docker Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

71. What are the networks that are available by default?


bridge – It is the default network all containers connect to if we will not specify the network.

none – connects to a container-specific network stack which will lack a network interface

host – connects to the host’s network stack – there will be no isolation between the host machine and the container, as far as network is concerned

72. Difference between Docker Image and container?


The runtime instance of docker image is the Docker container. Docker Image will not have a state, and its state will never change as it will just set of files whereas docker container will have its execution state.

73. What is the use case for Docker?


There are use cases where we can use Docker in production.

74. How exactly are containers (Docker in our case) different from hypervisor virtualization (vSphere)? What are the benefits?


To run an application in a virtualized environment (example for vSphere), we first are required for creating a VM, install an OS inside and only then deploy the application. To run the same application in docker, all we require is to deploy that application in Docker. There is no need for an additional OS layer. We just deploy the application with its dependent libraries, docker engine (kernel, etc.) which will provide the rest.

Another benefit of Docker is speed of deployment.

ACME inc. will require virtualization of the GOOD APP for testing purposes.

75. Docker is the new craze in virtualization and cloud computing. Why are people so excited about it?


Docker is fast, easy for using and a developer-centric DevOps-ish tool. It is easy to package and ship code. Developers will want tools which abstract away a lot of the details of that process. They will just want to see their code working. That will lead to all sorts of conflicts with Sys Admins when code will be shipped around and turns out not to work somewhere other than the developer’s environment. Docker will turn to work around that by making code as portable as possible and making that portability user-friendly and simple.

76. Do you think open source development has heavily influenced cloud technology development?


I think open source software will be closely tied to cloud computing. Both in terms of the software running in the cloud and the development models which have enabled the cloud. Open source software will be cheap, it’s low friction both from an efficiency and a licensing perspective.

77. Can you give us a quick rundown of what we should expect from your Docker presentation at OSCON this year?


It is aimed at Developers and SysAdmins who want to get started with Docker in a very hands on way. We’ll teach the basics of how to use Docker and how to integrate it into daily workflow.

78. Mention some commonly used Docker Commands?


Some among the most commonly used Docker Commands will be as follows:

  • Command      –       Description
  • Dockerd         –      Launch the Docker Daemon
  • Info                –         Displays  information System-Wide
  • Version           –       Displays the Docker Version information
  • Build              –         Builds images for Docker files
  • Inspect            –       Returns low-level information on an image or container
  • History           –        Shows Image History
  • Commit          –       Creates new images from Container changes
  • Attach            –        Attaches to a running container
  • Load              –          Load an image from STDIN or tar archive
  • Create          –           Create a new container
  • Diff            –            Inspect changes on a container’s file system
  • Kill              –             Kill a running container

79. How will you monitor Docker in production?


Docker provides functionalities like docker stats and docker events to monitor docker in production. Docker stats provides CPU and memory usage of the container. Docker events provide information about the activities taking place in the docker daemon.

80. Where do you think Docker is being used?


When asked such a question, respond by talking about applications of Docker. Docker is being used in the following areas:

Simplifying configuration: Docker lets you put your environment and configuration into code and deploy it.

Code Pipeline Management: There are different systems used for development and production. As the code travels from development to testing to production, it goes through a difference in the environment. Docker helps in maintaining the code pipeline consistency.

Developer Productivity: Using Docker for development gives us two things – We’re closer to production and the development environment is built faster.

Application Isolation: As containers are applications wrapped together with all dependencies, your apps are isolated. They can work by themselves on any hardware that supports Docker.

Debugging Capabilities: Docker supports various debugging tools that are not specific to containers but work well with containers.

Multi-tenancy: Docker lets you have multi-tenant applications avoiding redundancy in your codes and deployments.

Rapid Deployment: Docker eliminates the need to boost an entire OS from scratch, reducing the deployment time.

81. What, in your opinion, is the most exciting potential use for Docker?


The most exciting potential use of Docker is its build pipeline. Most of the Docker professionals will be seen using hyper-scaling with containers, and indeed get a lot of containers on the host which it can run on. These will be known to be blatantly fast. Most of the development – test build pipeline will be completely automated using the Docker framework.

82. Why is Docker the new craze in virtualization and cloud computing?


Docker will be the newest and the latest craze in the world of Virtualization and also Cloud computing because it will be an ultra-lightweight containerization app which is brimming with potential to prove its mettle.

83. Why do my services take 10 seconds to recreate or stop?


Docker compose stop attempts to stop a specific Docker container by sending a SIGTERM message. Once this message is delivered, it CaaS waits for the default timeout period of 10 seconds and once the timeout period is crossed, it will then send out a SIGKILL message for the container – in order to kill it forcefully. If we are actually waiting for the timeout period, then it will mean that the containers will not shut down on receiving SIGTERM signals / messages.

In an attempt to solve this issue, the following is what we will do:

1. We can ensure that we are using the JSON form of the CMD and also the ENTRYPOINT in dockerfile.

2. Use [“program”, “argument1”, “argument2”] instead of sending it as a plain string like this – “program argument1 argument2”.

3. Using the string form, which will make Docker run the process using bash which will not handle signals properly. Compose always uses the JSON form.

4. If it is possible then modify the application which we are intended to run by adding an explicit signal handler for the SIGTERM signal

5. Also set the stop_signal to a proper signal which the application will understand and also know how to handle it.

84. How do I run multiple copies of a Compose file on the same host?


Docker compose will make use of the Project name for creating unique identifiers for all of the project’s containers and resources. In order to run multiple copies of the same project, we will be required to set a custom project name using the –p command line option or we could use the COMPOSE_PROJECT_NAME environment variable for this purpose.

85. What’s the difference between up, run, and start?


On any given scenario, we will always want docker-compose up. Using the command UP, we will start or restart all the services which are defined in a docker-compose.yml file. In the “attached” mode, that will also be the default mode – we will be able to see all the log files from all the containers. In the “detached” mode, it can exit after starting all the containers that will continue to run in the background showing nothing over in the foreground.

Using docker-compose run command; we can be able to run the one-off or the ad-hoc tasks which will be required to be run as per the Business needs and requirements. This will require the service name to be provided which we would want to run and based on that, it can only start those containers for the services which the running service will depend on. Using the run command, we can run tests or perform any of the administrative tasks like removing / adding data to the data volume container. It will also be very similar to the docker run –ti command that opens up an interactive terminal to the containers and an exit status which will match with the exit status of the process in the container.

Using the docker-compose start command; we will only restart the containers which were previously created and were stopped. This command will never create any new Docker containers on its own.

86. What’s the benefit of “Dockerizing?”


Dockerizing enterprise environments will help teams to leverage over the Docker containers to form a service platform such as a CaaS (Container as a Service). It will provide teams with necessary agility, portability and also lets them control staying within their own network / environment.

Most of the developers opt for using Docker and Docker alone because of the flexibility and also the ability that it will provide to quickly build and ship applications to the rest of the world. Docker containers will be portable and these will run on any environment without making any additional changes when the application developers will have to move between Developer, Staging and Production environments. This whole process will be seamlessly implemented without the need of performing any recording activities for any of the environments. These not only will help to reduce the time between these lifecycle states, but also will ensure that the whole process can be performed with utmost efficiency. There is every possibility for the Developers for debugging any certain issue, fix it and will also update the application with it and propagate this fix to the higher environments with utmost ease.

The operations teams will handle the security of the environments while also allow the developers to build and ship the applications in an independent manner. The CaaS platform which is provided by Docker framework will deploy on-premise and can also be loaded with full of enterprise level security features like role-based access control, integration with LDAP or any Active Directory, image signing and etc. Operations teams will have to heavily rely on the scalability provided by Docker and will also leverage over the Dockerized applications across any environments.

Docker containers will be so portable that it will allow teams to migrate workloads which will run on an Amazon’s AWS environment to Microsoft Azure without changing its code and also with no downtime at all. Docker will allow teams to migrate these workloads from their cloud environments to their physical data centers and vice versa. This also will enable the Organizations to focus on the infrastructure from the gained advantages both monetarily and also the self-reliability over Docker. The lightweight nature of Docker containers are compared to traditional tools such as virtualization, combined with the ability for Docker containers to run within VMs, allowing teams to optimize their infrastructure by 20X, and save money in the process.

87. How many containers can run per host?


Depending on the environment where Docker hosts the containers, there will be as many containers as the environment will support. The application size, available resources such as CPU, memory will decide on the number of containers which will run on an environment. Though containers will create newer CPUs on their own but they will definitely provide efficient ways of utilizing the resources. The containers themselves are super lightweight and will only last as long as the process they are running.

88. Is there a possibility to include specific code with COPY/ADD or a volume?


This will be easily achieved by adding either the COPY or the ADD directives in dockerfile. This can count to be useful if we want to move code along with any of Docker images, example, sending code an environment up the ladder – Development environment to the Staging environment or from the Staging environment to the 

Production environment. Having said that, we might come across situations where we will be required to use both approaches. We will have the image include the code using a COPY, and use a volume in Compose file to include the code from the host during development. The volume will override the directory contents of the image.

89. Will cloud automation overtake containerization any sooner?


Docker containers will gain the popularity each passing day and definitely can be a quintessential part of any professional Continuous Integration / Continuous Development pipelines. There is equal responsibility on all the key stakeholders at each Organization for taking up the challenge of weighing the risks and gains on adopting technologies which are budding up on a daily basis. Docker is extremely effective in Organizations that appreciate the consequences of Containerization.

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


We will identify the status of a Docker container by running the command ‘docker ps –a’, that will in turn list down all the available docker containers with its corresponding statuses on the host. From there we will easily identify the container of interest to check its status correspondingly.

91. What are the differences between the ‘docker run’ and the ‘docker create’?


The most important difference is that by using the ‘docker create’ command we will create a Docker container in the Stopped state. We will also give it with an ID which can be stored for later usages as well.

This will be achieved by using the command ‘docker run’ with the option –cidfile FILE_NAME as like this:

  • ‘docker run –cidfile FILE_NAME’

92. Can you remove a paused container from Docker?


It is not possible for removing a container from Docker which is just paused. It is a must which a container will be in the stopped state, before it will be removed from the Docker container.

93. Is there a possibility that a container can restart all by itself in Docker?


No, it is not possible. The default –restart flag is set for never restart on its

94. What is the preferred way of removing containers – ‘docker rm -f’ or ‘docker stop’ then followed by a ‘docker rm’?


The best and the preferred way for removing containers from Docker is to use the ‘docker stop’, as it will allow sending a SIG_HUP signal to its recipients providing them the time which is required for performing all the finalization and cleanup tasks. Once this activity can be completed, we will then comfortably remove the container using the ‘docker rm’ command from Docker and thereby updating the docker registry as well.

95. Are you aware of load balancing across containers and hosts? How does it work?


While using docker service with multiple containers across different hosts, you come across the need to load balance the incoming traffic. Load balancing and HAProxy is basically used to balance the incoming traffic across different available(healthy) containers. If one container crashes, another container should automatically start running and the traffic should be re-routed to this new running container. Load balancing and HAProxy works around this concept.

Are you looking training with Right Jobs?

Contact Us

Popular Courses