Step-by-Step Guide: Installing Docker on Ubuntu and Linux Servers

 


What is Docker?

Docker is containeraise platform where we Build, test, Deploy application, We run docker container for our software with needful code and libraries 

How to installl Docker on Ubuntu or Linux Server?

Follow below mention step to get install Docker on your Ubuntu or Linuix Server

First Update and Upgrade your linux system

sudo apt-get update

sudo apt-get upgrade -y

Now install few prerequisite packages

sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

Add GPG key

sudo mkdir -p /etc/apt/keyrings

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \

"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


Final Step to Install Docker On your Linux machine

Give permission to GPG key

sudo chmod a+r /etc/apt/keyrings/docker.gpg

Run Update command

sudo apt-get update

Lets start installing docker to Running below command

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y

Welcome to Docker

sudo docker run hello-world

Add User into group

sudo usermod -aG docker ubuntu

Edit file

sudo nano /etc/group

Below Are the some usefull Commands

1) to Show Docker images 

    docker images

2) to Show running container

    docker ps

3) to show Dead or inactive Container

    docker ps -a

4) to Run Server (for Exmple nginx

    docker run --name myweb -p 8090:80 -d nginx

5) if you want to stop container

    docker stop <container name or id>

6) if you want to start container

    docker start <Container name or id>

7) to show files of containers

    docker exec <container name or id> ls / 

8) to Enter to the container as root user

    docker exec -it <container_name_or_id> /bin/bash 

9) for remove container and images

    docker rm <container_name_or_id>

    docker rmi <images remove>

10)to check running processed

    ps -ef #to check running processed

    cd /var/lib/docker/containers #show running container


Frequently Asked Questions (FAQs)

Q1: What is Docker?
Ans: Docker is a containerization platform for building, testing, and deploying applications.

Q2: How do I install Docker on Ubuntu or Linux Server?
Ans: You can install Docker by updating your system, installing prerequisites, adding Docker's GPG key and repository, and running installation commands.

Q3: How do I verify Docker installation?
Ans: Run sudo docker run hello-world to verify a successful Docker installation.

Q4: How can I add a user to the Docker group?
Ans: Add a user to the Docker group with sudo usermod -aG docker <username>.

Q5: What are some essential Docker commands?
Ans: Key commands include docker images, docker ps, docker run, docker stop, docker start, and docker exec for container management.

Post a Comment

Previous Post Next Post