Docker – Introduction, Architecture, and Most used Commands

Introduction

Docker has revolutionised the way we build, ship, and run applications. It enables developers to package applications along with their dependencies into lightweight containers that can run consistently across different environme…


This content originally appeared on DEV Community and was authored by akhil mittal

Introduction

Docker has revolutionised the way we build, ship, and run applications. It enables developers to package applications along with their dependencies into lightweight containers that can run consistently across different environments. In this post, we will dive into Docker’s architecture and cover its basic commands in detail.

Why Docker is Important for DevOps?

Consistency: Docker ensures that applications run the same way in development, testing, and production environments.

Isolation: Containers provide isolated environments for applications, preventing conflicts and improving security.

Scalability: Docker makes it easy to scale applications horizontally by adding more containers.

Efficiency: Containers are lightweight and use system resources more efficiently compared to traditional virtual machines.

Docker Architecture:

Image description

Docker architecture consists of the following key components:

Docker Client
Docker Daemon
Docker Images
Docker Containers
Docker Registry

  1. Docker Client
    The Docker client is a command-line interface (CLI) that allows users to interact with Docker. Users can issue commands such as docker build, docker run, and docker stop through the Docker client.

  2. Docker Daemon
    The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. It communicates with the Docker client to execute commands.

  3. Docker Images
    Docker images are read-only templates that contain the instructions to create a Docker container. Images are built using Dockerfiles, which specify the steps needed to create the image.

  4. Docker Containers
    Containers are runnable instances of Docker images. They are isolated environments where applications run with their dependencies. Containers can be started, stopped, and deleted as needed.

  5. Docker Registry
    A Docker registry is a storage and distribution system for Docker images. Docker Hub is a public registry, but private registries can also be set up for internal use.

Basic Docker Commands

Now, let's explore the basic Docker commands and their usage.

docker --version: Displays the installed Docker version.
$ docker --version

docker info: Provides detailed information about the Docker installation, including the number of containers and images.
$ docker info

docker pull: Pulls an image from a Docker registry.
$ docker pull

docker images: Lists all the Docker images available on the system.
$ docker images

docker run: Creates and starts a new container from an image.
$ docker run -it ubuntu
-it: Runs the container in interactive mode with a terminal.
ubuntu: Specifies the image to use.

docker ps: Lists all running containers.
$ docker ps

To list all containers (running and stopped), use:
$ docker ps -a

docker stop: Stops a running container.
$ docker stop

docker start: Starts a stopped container.
$ docker start

docker rm: Removes a stopped container.
$ docker rm

docker rmi: Removes a Docker image.
$ docker rmi

docker build: Builds a Docker image from a Dockerfile.
$ docker build -t my-image:latest .
-t: Tags the image with a name and optional tag (e.g., my-image:latest).
. Specifies the directory containing the Dockerfile.

docker exec: Runs a command in a running container.
$ docker exec -it /bin/bash
-it: Runs the command in interactive mode with a terminal.
/bin/bash: Specifies the command to run (in this case, starting a bash shell).

docker logs: Fetches the logs of a container.
$ docker logs

docker inspect: Displays detailed information about a container or image.
$ docker inspect

Conclusion

Docker is a powerful tool that simplifies the process of deploying and managing applications in isolated containers. Understanding Docker's architecture and mastering its basic commands are crucial steps for any DevOps engineer.


This content originally appeared on DEV Community and was authored by akhil mittal


Print Share Comment Cite Upload Translate Updates
APA

akhil mittal | Sciencx (2024-09-13T12:48:01+00:00) Docker – Introduction, Architecture, and Most used Commands. Retrieved from https://www.scien.cx/2024/09/13/docker-introduction-architecture-and-most-used-commands/

MLA
" » Docker – Introduction, Architecture, and Most used Commands." akhil mittal | Sciencx - Friday September 13, 2024, https://www.scien.cx/2024/09/13/docker-introduction-architecture-and-most-used-commands/
HARVARD
akhil mittal | Sciencx Friday September 13, 2024 » Docker – Introduction, Architecture, and Most used Commands., viewed ,<https://www.scien.cx/2024/09/13/docker-introduction-architecture-and-most-used-commands/>
VANCOUVER
akhil mittal | Sciencx - » Docker – Introduction, Architecture, and Most used Commands. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/13/docker-introduction-architecture-and-most-used-commands/
CHICAGO
" » Docker – Introduction, Architecture, and Most used Commands." akhil mittal | Sciencx - Accessed . https://www.scien.cx/2024/09/13/docker-introduction-architecture-and-most-used-commands/
IEEE
" » Docker – Introduction, Architecture, and Most used Commands." akhil mittal | Sciencx [Online]. Available: https://www.scien.cx/2024/09/13/docker-introduction-architecture-and-most-used-commands/. [Accessed: ]
rf:citation
» Docker – Introduction, Architecture, and Most used Commands | akhil mittal | Sciencx | https://www.scien.cx/2024/09/13/docker-introduction-architecture-and-most-used-commands/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.