How to Install Docker on Ubuntu

What is Docker on Ubuntu?

Docker is a containerization platform that allows you to package and deploy applications as containers. A container is a self-contained, lightweight, and portable package that includes everything an application needs to run, including the application code, libraries, dependencies, and runtime.

Docker allows you to deploy and run applications in containers on any platform, including Ubuntu. This makes it easy to build, test, and deploy applications consistently across different environments, such as development, staging, and production.

To use Docker on Ubuntu, you will need to install the Docker engine, which is the software that runs and manages containers on your system. You can install the Docker engine using the package manager apt.

Once the Docker engine is installed, you can use the docker command-line tool to manage containers and images on your system. You can use docker pull to download images from a registry, such as Docker Hub, and use docker run to create and start a new container from an image.

You can also use Docker Compose to define and run multi-container applications. Docker Compose uses a configuration file to define the services, dependencies, and configuration of an application. You can use docker-compose up to start all the services defined in the configuration file.

Docker is widely used in the development and deployment of applications, particularly in the microservices architecture. It allows developers to build, test, and deploy applications in a consistent and portable way, making it easier to manage and scale applications in different environments.

Here is how to install Docker on Ubuntu:

Update your local package index:

sudo apt update

Install packages to allow apt to use a repository over HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Use the following command to set up the stable repository:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Update the package index again:

sudo apt update

Install the latest version of Docker Engine – Community and containerd:

sudo apt install docker-ce docker-ce-cli containerd.io

Verify that Docker has been installed correctly by running the hello-world image:

sudo docker run hello-world

If the installation was successful, you will see a message similar to the following:

Copy codeHello from Docker!
This message shows that your installation appears to be working correctly.

You can now start using Docker.

Note: If you want to install a specific version of Docker, you can use the following command instead of step 6:

sudo apt install docker-ce=<VERSION_STRING>~ce~3-0~ubuntu

Replace <VERSION_STRING> with the version that you want to install. You can find the available versions of Docker by running the following command:

apt-cache madison docker-ce
Visited 61 times, 1 visit(s) today

Leave a Comment

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

Scroll to Top