Docker - samruddhipatil12/wiki-pages GitHub Wiki

What is Docker?

  Docker is like a virtual box for your application. 

Key Concepts

  • Containers: These are lightweight, stand-alone, and executable packages of software that include everything needed to run an application: code, runtime, system tools, libraries, and settings. Containers ensure that the application works in any environment.

  • Images: A Docker image is a read-only template that contains the application and its environment. It’s like a blueprint for creating containers. You can think of it as a snapshot of the application and its dependencies at a particular point in time.

  • Dockerfile: This is a text file with a list of commands on how to build a Docker image. It’s like a recipe that tells Docker how to create the image step-by-step.

  • Docker Hub: A public repository where Docker users can store and share their Docker images. Think of it as an app store for Docker images.

How Docker Works ?

  • Build: You write a Dockerfile that contains all the instructions on how to set up the application. This might include installing software packages, copying files, and setting configuration options.

  • Image Creation: Using the Dockerfile, you create a Docker image. This image contains everything your application needs to run.

  • Run: You run the Docker image to create a container. The container is an instance of the image and contains the running application.

Benefits of Using Docker :

  • Consistency: Containers ensure that the application will run the same way, regardless of where it is deployed.

  • Isolation: Each container is isolated from others, preventing conflicts between applications.

  • Portability: Containers can run on any machine that has Docker installed, making it easy to move applications between different environments (development, testing, production).

  • Efficiency: Containers share the host system’s OS kernel and do not require a full operating system, making them lightweight and faster to start compared to traditional virtual machines.

Example:

Imagine you’re a developer working on a web application. Traditionally, you’d have to make sure everyone on your team has the right software versions installed, which can be a hassle. With Docker:

  • Create a Dockerfile: Write down all the steps needed to set up your web application.

  • Build an Image: Run a command to create an image from this Dockerfile.

  • Run Containers: Share the image with your team. They can run it in containers on their machines, and it will work exactly the same as on yours.