Open In App
Related Articles

How To Install and Configure Docker in Ubuntu?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Docker is a platform and service-based product which utilizes OS-level virtualization to deliver software in packages called containers. Containers are separated from one another and bundle their own software, libraries, and configuration files. Docker is written in the Go language. Docker can be installed in two versions Docker CE(Community Edition) and Docker EE(Enterprise Edition). For small-scale projects, or for learning, we can use Docker CE.

With Hostinger VPS services, you have greater flexibility and control over your hosting environment, and you get far more value for your money.

Hostinger offers VPS templates with the most popular frameworks and CMS preinstalled. Applications built with Node.js, Django, Rails, WordPress, Joomla, and Drupal can be chosen and launched quickly.

4 active plans with prices ranging from ₹449/mo to ₹1499/mo:

  • KVM1
  • KVM2
  • KVM4
  • KVM8

These are designed to satisfy various needs. The KVM2 plan is the most affordable and well-liked by users of lightweight apps.

Full root access, support for many operating systems, excellent performance, improved security and backup, one-click installation, worldwide data centres, and scalability are features of Hostinger’s VPS service.

Operating System Requirements for Docker Installation on Ubuntu

Steps for Installing Docker on Ubuntu

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

$ sudo apt update

Step 2: Install Docker using the following command

$ sudo apt install docker.io -y

Install docker

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

$ sudo systemctl enable docker
Enable docker
$ sudo systemctl start docker
Start docker

 Step 4: Check 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

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

Docker Version

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.

docker build -t <Name of the Dockerfile> 

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 <image_name>
To give name of container
$ docker run --name <container_name> <image_name>

To Know more docker commands read Docker Commands.

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.

  • List Docker images: “docker images” this command will list all the docker images which are available in the docker.
  • To Pull Docker Images: “docker pull <Name of the image>” it will pull the required images which are stored in the docker hub registry or repository.

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

Docker Network

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.

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 <container_id> <new_image_name>

FAQs On Installing Docker in Ubuntu

1. How to Install Docker in Windows?

To Know how to Install docker on windows please refer to the How to Install Docker on Windows?.

2. How Do I Know Docker is Installed on Ubuntu?

1. First check for the docker command.

docker ps 

If the command mentioned above gives output without any errors then you can say that docker is installed.

2. Check the status of the docker.

sudo systemctl status docker.

If Docker is running, the output will show the service status as “active (running)”.

3. How To Start Docker In Ubuntu Terminal?

To start the docker in ubuntu terminal use the following command.

sudo service docker start

4. What Is Docker Used For?

Docker is an open-source containerization platform. Docker is mainly used for the containerization of applications it is well suited for the microservice applications.




Last Updated : 07 Feb, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads