How to Install and Configure Docker in Ubuntu? (original) (raw)

Last Updated : 27 Aug, 2025

Docker can be installed in two versions Docker CE(Community Edition) and Docker EE(Enterprise Edition). For small-scale projects or learning, we can use Docker CE.

Before installing Docker on Ubuntu, We have to ensure that the system meets the following requirements:

**Tip for Optimized Hosting:

**Hostinger offers high-performance cloud servers and **Linux-based VPS hosting that are ideal for Docker environments. These hosting plans ensure that your infrastructure meets the kernel version and resource requirements needed for smooth Docker operation. With **24/7 support and **scalable performance, you can efficiently deploy Docker containers on a server tailored for **growth and reliability.

For seamless Docker deployment,

For Example my system configuration are as follows:

configure

Steps for Installing Docker on Ubuntu

The following are the steps that guides you in installing the Docker on Ubuntu:

**Step 1: Update Software Repositories using the following command on the terminal.

sudo apt update

sudo-apt-update

**Step 2: Install Docker using the following command

sudo apt install docker.io -y

sudo-apt-install

**Step 3: Enable and start the docker service by using the following commands.

sudo systemctl enable docker --now

**Step 4: Check Docker Version.

docker --version

docker---version

Executing the Docker Command Without Sudo

We will get a permission denied error as a regular user doesn't have permission to execute docker commands. Know we need to add the the user to the required group.

**Step 1: So we need to add an Ubuntu user to the docker group.

#sudo usermod -aG docker $USER
or
#sudo usermod -aG docker ubuntu

getent group docker

newgrp docker

add-the-user

**Step 2: Restart the docker daemon which is already running. After restarting only the changes will comes into effect.

sudo service docker restart

**Step 3: Leave the current SSH terminal and re-login with SSH. then carry out.

docker ps

add-the-user

Using the Docker Commands

You need to master the docker commands to work more efficiently in the docker following are the some of the commands which are used in docker on daily bases.

Docker Build Command

After writing the dockerfile know you need to build the dockerfile into the docker image. This is docker image is further used to run the docker containers. Foillowing is the command which is used to build the docker image.

Jenkins-Dockerfile

docker build -t

**Example:

docker build -t myimg:latest .

buildimage

Docker Run Command

This command is used to run a container from an image. The docker run command is a combination of the docker create and docker start commands. It creates a new container from the image specified and starts that container. if the docker image is not present, then the docker run pulls that.

$ docker run
To give name of container
$ docker run --name

**Example:

docker run myimg

run-docker-run

Working with Docker Images

If you are a Docker developer, you might have noticed that working with multiple Docker Images at the same time might be quite overwhelming sometimes. Managing numerous Docker Images all through a single command line is a very hefty task and consumes a lot of time. In this article, we are going to discuss some important Docker Images commands that would make your life easier. Managing Images with the help of these commands will be very easy and will save you a lot of time.

Following are the some of the docker images which are used on the daily bases.

To know more commands which are used to work with docker images refer to the "Working with Docker Images".

Docker Network Commands

Docker Networking allows you to create a Network of Docker Containers managed by a master node called the manager. Containers inside the Docker Network can talk to each other by sharing packets of information. In this article, we will discuss some basic commands that would help you get started with Docker Networking. To know more about Docker networking refer to the Docker Networking.

docker network ls

docker-network

docker-network-inspect

How to Commit Changes in a Docker Container?

Docker commit command is used to convert the current state of docker container to the docker new image.

First you need to know the ID of the docker container which you want to the docker images after that run the following command.

docker commit

Example of Commit a Docker Container

docker run -dit --name myc1 ubuntu:latest

docker-commit

docker commit myc1 mynewimg

docker images

dockercommit