Docker fundamentals

Nikhil Wilson - Sep 18 - - Dev Community

This is Task 1/40 of the Certified Kubernetes Administrator(CKA) 2024 video series by Piyush Sachdeva. Tech Tutorials with Piyush
Video from Day 1 for Docker tutorials for Beginners

Docker is an open-source tool that containerizes an entire application along with its dependencies, codebase, and even the underlying operating system. Users can define a Dockerfile specifying all the necessary build requirements, pass it to the Docker daemon, and create an image of the application. This image can then be shared with others, who can simply run it to obtain a fully operational container. No more hassles with installation, fixing dependencies, or meeting other prerequisites.

Here’s a simple use case:

Imagine you're building a web application using Node.js v16.20.2 and React v16.10.1. You’ve used npm to install all the required dependencies based on the framework. Everything works fine until you share it with a friend for testing. Now your friend needs to set up a virtual machine and install the necessary frameworks and packages, or reinstall Node.js, React, and npm to match your environment. That’s time wasted—time that could be spent testing the application!

simple docker workflow

Instead, you can create a Dockerfile that handles the installation of dependencies, copies the codebase, and exposes the application’s port. After building the image, you can upload it to a registry like Docker Hub. The tester can then pull the image, run it to create a container, and—just like that—the web application is up and running for testing. This ensures that the development, testing, and production teams are all working with the same image, resolving the infamous "it works on my machine" issue.

Let’s also take a look at Docker's architecture:

docker architecture

  1. The user defines a Dockerfile with all the necessary build requirements.
  2. The Docker daemon (Dockerd) uses the Dockerfile to build an image of the application with the docker build command.
  3. With the docker push command, the image is uploaded to a Docker image registry, such as Docker Hub, where it can be versioned and tracked.
  4. Users can then download the image from the registry using the docker pull command.
  5. Finally, a container is created from the image using the docker run command, and the application is ready to use.

In summary, Docker simplifies the entire process of application development, testing, and deployment by packaging everything into a single image that can be shared and run anywhere. With Docker, you eliminate the frustrating "works on my machine" issue and ensure that all teams—whether in development, testing, or production—are using the same environment.

. .
Terabox Video Player