Docker Basics

what is docker

Docker is a platform used for developing, shipping, and running applications. It's based on containerization technology, which allows developers to package up an application with all of its dependencies into a standardized unit called a container. These containers can then be easily moved between environments, such as from a developer's laptop to a testing environment or from a data center to the cloud, without any changes.

Some key benefits of using Docker include:

  • Consistency: Docker ensures that applications run consistently across different environments, reducing the likelihood of "it works on my machine" issues.

  • Isolation: Each Docker container is isolated from other containers and the host system, providing security and preventing conflicts between applications and their dependencies.

  • Portability: Docker containers can be easily moved between different environments, making it easy to deploy applications across different platforms, from development to production.

  • Resource Efficiency: Docker containers share the host system's kernel and resources, making them lightweight and efficient compared to traditional virtual machines.

what is Container & Containerization

Container refers to a lightweight, stand-alone, executable package of a piece of software that contains all the libraries, configuration files, dependencies, and other necessary parts to operate the application.

Containerization:

Containerization is a lightweight form of virtualization that allows you to package and isolate an application along with its dependencies into a standardized unit called a container.

Containerization is a system of intermodal freight transport using intermodal containers (also called shipping containers and ISO containers). Containerization is also referred as "Container Stuffing" or "Container Loading", which is the process of unitization of cargoes in exports.

Virtualization:

Virtualization is technology that lets you create useful IT services using resources that are traditionally bound to hardware. It allows you to use a physical machine’s full capacity by distributing its capabilities among many users or environments.

Docker container vs Virtualization:

Docker cheat sheet:

Here are some of the most important Docker Commands:

  1. To run a Docker Container:

      docker run <image_name>
    
  2. To run a Docker Container in detached mode (in the background):

      docker run -d <image_name>
    
  3. To run a Docker Container with a specific name:

      docker run --name <container_name> <image_name>
    
  4. To run a Docker Container and expose ports:

      docker run -p <host_port>:<container_port> <image_name>
    
  5. To run a Docker Container with environment variables:

      docker run -e <key>=<value> <image_name>
    
  6. To run a Docker Container with volumes:

      docker run -v <host_path>:<container_path> <image_name>
    
  7. To run a Docker Container with interactive mode (to enter the container's shell):

      docker run -it <image_name>
    

    -it: Interactive Terminal

  8. To run a Docker Container with resource constraints:

      docker run --cpu-shares=<value> --memory=<value> <image_name>
    
  9. List images in Docker

      docker images
    
  10. To see the running containers

    docker ps
    
  11. To see all the containers, running or stopped

    docker ps -a
    
0
Subscribe to my newsletter

Read articles from Md. Wahaduzzaman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Md. Wahaduzzaman
Md. Wahaduzzaman