Skip to main content

Command Palette

Search for a command to run...

Docker

Updated
•3 min read•View as Markdown
S

I am Shradha Arsewar working as Associate software Engineer used to work as a Intern in Product Company (PTC). Likes to share knowledge

Introduction:

Lets consider an example, we are developed an application which is running on Dev environment but not in Prod servers. So here one of the major problem is Dependencies.

For example, dev team developed a Java application and their systems has all required modules and dependencies which are used to run the application. But Those dependencies are not installed on production servers. In this case we cant able to run the applications on Prod servers.

To avoid these kind of issues, we started implementing containerization. Containerization is a process of packing the application along with its dependencies.

Zoomed view

To implement containerization, there are lot of tools like Docker, Podman and LXC/LXD. Out of these Docker is the best tool to create containers.

Docker:

Docker is an open-source platform that allows developers to build, package, and run applications in containers. Containers are lightweight, standalone, and executable units that include everything needed to run a piece of software: code, runtime, libraries, and dependencies.

Keywords in Docker:

Containers:

  • A Docker container is a lightweight, standalone, and executable software package that encapsulates an application and all its dependencies, including the operating system, libraries, and runtime environment.

  • Containers created from a Docker image and can be run on any machine that has Docker installed, providing a consistent and isolated environment for the application to run.

Images:

  • A Docker image is a read-only template that contains a set of instructions for creating a container that can run on the Docker platform.

  • It provides a convenient way to package up applications and all the dependencies.

  • We can store these images on registry either publicly or privately.

Registry:

  • A Docker registry is a repository for storing and sharing the docker images. Docker is configured to pull the images from Docker Hub by default, but organisations often use private registries for their projects like ECR, ACR, GCT etc.

    Zoomed view

    Docker Architecture:

  • Docker Client:
    The tool you interact with when you run commands like docker run or docker build.
    It communicates with the Docker Daemon. Commands are sent from client → daemon.

  • Docker Daemon:
    The engine that does the heavy lifting. it communicates with other daemons. Runs on the host machine.

  • The Docker Host

The Docker Host is the physical or virtual machine that provides the complete environment for executing and running containers. It comprises:

  • The Operating System (and its kernel).

  • The Docker Daemon.

  • Images that have been pulled or built.

  • Running Containers.

  • Networks and Storage components.

  1. Docker Registry:

A Docker Registry is a stateless, scalable storage system for Docker images.

  • Public Registry: The default public registry is Docker Hub, which contains a vast collection of community and official images.

  • Private Registries: Organizations often use private registries (like Harbor, AWS ECR, or Google Artifact Registry) to store proprietary images for security and control.

Docker Login Commands

Log in to a Registry

docker login

Logout from a Registry

docker logout

Build an image

docker build -t <image_name> .

Pulling an Image

docker image pull nginx

Pushing an Image

docker image push <usernameofregistry:Imagename: tag>
docker image push eon01/nginx localhost:5000/myadmin/nginx

Login into Docker hub

docker login -u <username>

Starting Containers

docker container start nginx

Stopping Containers

docker container stop nginx

Check the Containers

docker ps

Container Logs

docker logs infinite

Listing Images

docker image ls