Search Tutorials

Top Docker (2024) Interview Questions | JavaInUse

Top Docker (2024) frequently asked interview questions.

In this post we will look at Docker Interview questions. Examples are provided with explanations.

Q: What is Docker?
Consider a scenario - You have just joined a new organization as a developer. You will now have to setup the project with the assistance of a fellow developer. He suggests you follow certain steps for setting up the required environment and then start the project deployable like a WAR. You do the same, but keep getting some or other issues regarding environment configuration. May be even your fellow developer has forgot some configuration property he might have set. Well you are stuck in such a situation. This is known as Dependency Hell. Other similar scenario of this dependency hell are - The application is running on my dev machine but not in production. Dont know what issue is. There is also other scenarios like Matrix of Hell. But this is mostly related to DEVOPS people. Docker to the rescue.
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.
Docker Tutorials

Q: How to deploy Spring Boot WAR to Docker?
Deploying Spring Based WAR Application to Docker

Q: How to deploy Spring Boot Microservice to Docker?
Deploying Spring Based JAR Application to Docker

Q: How to deploy multiple Microservices to Docker?
Deploying Multiple Spring Boot Microservices using Docker Networking

Q: What are the scenarios in which a Java Developer will use Docker?
Following scenarios a java developer can use docker-
  • Sharing development workspace, with preconfigured development environment.
  • Continuous integration is one of the most popular use cases for Docker. Teams looking build and deploy their applications quickly use Docker, combined with ecosystem tools like Jenkins, to drive apps from dev, testing staging and into production without having to change any code.
  • Running UAT's using Docker

Q: What is docker compose?
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration.
Using docker-compose we will be creating the custom network named consumer-producer and then starting the containers employee-producer and employee consumer.
docker interview questions
Deploying Multiple Spring Boot Microservices using Docker Compose

Q: What is Dockerfile used for?
Docker file is a list of commands that we want the docker engine to execute.
From openjdk:8
copy ./target/employee-producer-0.0.1-SNAPSHOT.jar employee-producer-0.0.1-SNAPSHOT.jar
CMD ["java","-jar","employee-producer-0.0.1-SNAPSHOT.jar"]

Q: How to deploy Multiple Services across multiple host machines?
This deployment across multiple hosts can be achieved using docker swarm. Using Docker Swarm we can scale the services horizontally by deploying the docker containers across multiple host machines. These host machines are called as nodes of a swarm.
Start Swarm nodes
Deploy Docker Swarm services using Play With Docker

Q: What is a Docker stack?
Suppose there are many services to be deployed using Docker Swarm. In such a case manually starting services is not feasible. We had faced a similar problem when deploying multiple services on a single host machine and the solution for this problem was to use Docker Compose to deploy Docker Services. Since Docker swarm involves deploying multiple services across various nodes we cannot use Docker Compose. But Docker Swarm provides something similar to Docker Compose called Docker Stack which can be used for deploying services in the swarm.
Docker Stack Tutorial
Deploy Docker Swarm services using Docker Stack

See Also

Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Java 8 Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Angular 2 Interview Questions