How to Install Docker and Use Basic Commands.

How to Install Docker and Use Basic Commands.

Introduction.

Docker is an open-source platform designed to automate the deployment, scaling, and management of applications by packaging them into lightweight, portable containers. Containers package up everything an application needs to run: the code, runtime, system tools, libraries, and settings.

Core Components:

  1. Images : Docker images are read-only templates, meaning they cannot be altered after creation. Changes result in a new image being created.
  2. Containers : Containers are created from Docker images and provide an isolated environment for running applications.
  3. Registries : A Docker registry is a centralized repository where Docker images are stored, managed, and distributed. It allows developers and teams to share and access Docker images, enabling efficient deployment of applications across different environments.
  4. Docker Engine : Docker Engine provides the foundation for Docker’s functionality, including building images, managing containers, and networking.

Docker installation.

STEP 1: Terminate any running Docker containers and remove their associated files from the system.

 sudo apt-get remove docker docker-engine docker.io
 sudo apt-get update
Screenshot 2024 12 06 122418

STEP 2: Install the docker use the following command,

sudo apt install docker.io
Screenshot 2024 12 06 122604

STEP 3: Enable and start the server.

sudo systemctl enable docker
sudo systemctl start docker
sudo systemctl status docker
Screenshot 2024 12 06 122729

STEP 4: Check the version installed using the following command.

docker --version
Screenshot 2024 12 06 151024

STEP 5: Check the docker images.

sudo docker images
Screenshot 2024 12 10 105907

There are no Docker images on my system.

STEP 6: Pull an image from the Docker hub.

sudo docker run hello-world
Screenshot 2024 12 10 110321

STEP 7: Now I check my images.

Screenshot 2024 12 10 110352

STEP 8: Display all the containers pulled.

sudo docker ps -a
Screenshot 2024 12 10 111540

STEP 9: Create the docker group.

sudo groupadd docker
Screenshot 2024 12 10 111951

STEP 10: As the next step, add the user to the Docker group by executing the following command:

sudo usermod -aG docker $USER
Screenshot 2024 12 10 112002

STEP 11: Docker to list all images stored on the system.

sudo docker images -a
Screenshot 2024 12 10 112008

STEP 12: Search for Docker images in the Docker Hub repository.

sudo docker search <image-name>
Screenshot 2024 12 10 112214

STEP 13: Pull the ubuntu docker image.

sudo docker pull ubuntu
Screenshot 2024 12 10 123519
Screenshot 2024 12 10 123534

STEP 14: Activate the Container.

“b1d9df8ab815” Replace your Image ID.

sudo docker run -it b1d9df8ab815 bin/bash
Screenshot 2024 12 10 123812

Conclusion.

Docker has become an integral tool in modern application development and operations. Its seamless integration with CI/CD pipelines and orchestration tools like Kubernetes ensures that modern teams can adopt faster, more agile, and error-free development practices.

Tags: No tags

Add a Comment

Your email address will not be published. Required fields are marked *