How to Install and Set Up Docker on Ubuntu

Docker is an open-source technology that is used to deploy applications through containers. It is a relatively new platform but is constantly updated and features a wide community of users.

Docker is a great tool that solves the age-old dilemma between developers and system administrators – while developers say that an app works on their machines, system admins worry about changing its libraries and requirements. With Docker, that is no longer a problem as it allows a more transparent method of communication.

It is essentially a virtual machine, that lets you run images. With Docker, you don’t need to worry about the requirements and that’s a perfect fit for many VPS projects.

Docker is highly popular among developers and can be installed without any problems in our favorite Linux distribution.

So, with this in mind, let’s learn how to install Docker on Ubuntu 22.04.

Why Install Docker on Ubuntu?

Let’s do a quick rundown of the main benefits users experience when using Docker.

Docker is adaptable allowing users to carry out continuous testing, deploy and check outcomes as many times as they want, with as many implications. It becomes a laboratory in itself where a user can experiment with new commands to fill in the container and make it functional in various tasks.

This utility also supports multi-cloud computing, which means it is adaptable to applications that use cloud computing for saving data on servers. Think of services like Microsoft Azure, Puppet, Ansible, OpenStack and others.

Segregation in an isolated environment is another core aspect of Docker that attracts developers. In addition, docker works with OS sensitive mount points like /sys and /proc which are read-only mounts.

How to Install Docker Automatically

You can easily install Docker by selecting one of our operating system templates. Start by selecting your VPS:

The main hPanel VPS page

Then, on the left side menu, navigate to OS & Panel -> Operating System:

Then at the Change OS section, search for “Docker” and select Ubuntu VPS template with Docker:

That’s it! Docker is now installed. All you will need to do is connect to the server using SSH and finish the setup.

How to Install Docker Manually

Let’s look at the steps on how to install Docker manually.

1. Access Your VPS

First, we have to connect to the server using SSH. If you’re having trouble, check out our PuTTY tutorial. Alternatively, you can use the integrated Hostinger browser terminal:

The VPS information page on hPanel. The Browser terminal window is highlighted

Pro Tip

Check out our KVM VPS plans if you want to run your application via Docker. With KVM virtualization, the software platform can support more applications than OpenVZ-based ones.

2. Update Your System

Then, the system needs to be updated to make it safer and reliable to install Docker. Run the following two commands:

sudo apt update
sudo apt upgrade

3. Install Prerequisite Packages

Once we have updated the system, we need to install some necessary packages before we are ready to install Docker script. You can do this with the help of a single command:

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

To better understand the command above here is a short description of what it means:

  • apt-transport-https – lets the package manager transfer files and data over https
  • ca-certificates – lets the web browser and system check security certificates
  • curl – transfers data
  • software-properties-common – adds scripts to manage the software

Sugested Reading

Discover our guide to learn how to list installed packages on Ubuntu.

4. Add the Docker Repositories

Now we have to add the Docker repositories. This will make the installation process much easier. This enables us to use the officially supported method of the installation.

First, we add the GPG key, by entering the following command in the command line:

curl -fsSL | sudo apt-key add -

Next, we add the repository:

sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

After that, just update the repository information:

sudo apt update

Make sure you are installing from the Docker repo instead of the default Ubuntu repo with this command:

apt-cache policy docker-ce

A correct output will look like the following with different version numbers:

   Installed: (none)
   Candidate: 16.04.1~ce~4-0~ubuntu
   Version table:
       16.04.1~ce~4-0~ubuntu 500

As you can see, docker-ce is not installed, so we can move on to the next step.

5. Install Docker on Ubuntu

We are almost done. Use the apt command to install Docker:

sudo apt install docker-ce

6. Check Docker Status

Once the installation is complete, it is a good idea to check the status of the service:

sudo systemctl status docker

You can also check Docker version you’ve just installed by running this command:


That’s it, you now know how to install Docker on Ubuntu. Easy, right? Let’s learn some Docker basics!

How to Start Using Docker on Ubuntu

Once Docker is installed, all we need to do is use the test image to check that everything is working as it should. Do this with the following command:

sudo docker run hello-world

Now, if we want to search for available images we just have to use the following command:

sudo docker search [search_query]

Just replace your query with the bracketed text.

For example, if we want to search for an image related to Debian, the command and output will look like this:

sudo docker search debian
Docker search results for the Debian query

Then, to download the image to our computer, we will use the name of the image along with the following command:

sudo docker pull [image_name]

For example, the command might look like this:

sudo docker pull debian

Normally, users will have several images in their system. We can list them with the command:

sudo docker images

The list will look much like the one you receive when you enter a search query.

After that, we can execute our image using the pull command and the Image ID.

sudo docker run -i -t [image]

There are options that extend the functionality of the command itself. For example, the -i option makes the image execution interactive. Or the -d option that executes it in the background.

Once we are running an image, we can end its execution by using the key combination CTRL+D.

Finally, if we want to use Docker without root privileges, we need to run the following command:

sudo usermod -aG docker $(whoami)

After that, restart the system, and the changes will be applied.

Using the Docker Command

The Docker command consists of passing options, commands, and arguments. The syntax will follow the following form:

docker [option] (command) [arguments]

To view all of the available subcommands use the following command:


To view the options available with a command:

docker docker-subcommand --help

Here are  Docker 18′ available subcommands:

docker attach – Attach local standard input, output, and error streams to a running container
docker build – Build an image from a Dockerfile
docker builder – Manage builds
docker checkpoint – Manage checkpoints
docker commit – Create a new image from a container's changes
docker config – Manage Docker configs
docker container – Manage containers
docker context – Manage contexts
docker cp – Copy files/folders between a container and local filesystem
docker create – Create a new container
docker diff – Inspect changes to files or directories on a container's filesystem
docker events – Get real time events from the server
docker exec – Run a command in a running container
docker export – Export a container's filesystem as a tar archive
docker history – Show the history of an image
docker image – Manage images
docker images – List images
docker import – Import the contents from a tarball to create a filesystem image
docker info – Display system-wide information
docker inspect – Return low-level information on Docker objects
docker kill – Kill one or more running containers
docker load – Load an image from a tar archive or STDIN
docker login – Log in to a Docker registry
docker logout – Log out from a Docker registry
docker logs – Fetch the logs of a container
docker manifest – Manage Docker image manifests and manifest lists
docker network – Manage networks
docker node – Manage Swarm nodes
docker pause – Pause all processes within one or more containers
docker plugin – Manage plugins
docker port – List port mappings or a specific mapping for the container
docker ps – List containers
docker pull – Pull an image or a repository from a registry
docker push – Push an image or a repository to a registry
docker rename – Rename a container
docker restart – Restart one or more containers
docker rm – Remove one or more containers
docker rmi – Remove one or more images
docker run – Run a command in a new container
docker save – Save one or more images to a tar archive (streamed to STDOUT by default)
docker search – Search the Docker Hub for images
docker secret – Manage Docker secrets
docker service – Manage services
docker stack – Manage stacks
docker start – Start one or more stopped containers
docker stats – Display a live stream of container(s) resource usage statistics
docker stop – Stop one or more running containers
docker swarm – Manage Swarm
docker system – Manage Docker
docker tag – Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
docker top – Display the running processes of a container
docker trust – Manage trust on Docker images
docker unpause – Unpause all processes within one or more containers
docker update – Update configuration of one or more containers
docker version – Show the Docker version information
docker volume – Manage volumes
docker wait – Block until one or more containers stop, then print their exit codes

Can't memorize the commands?

Check out our Docker cheat sheet

Understanding Docker

Its main novelty is that it allows you to “package” an application or a set of services in containers. A Docker container is an instance of an application that contains all the libraries and components necessary for an application to work. From a practical point of view, a container is like a reduced virtual machine that functions independently from the operating system where a specific application or service is executed.

A Docker container is generated from an image that is the result of the packaged app or service. It can contain a complete operating system or pre-installed applications. That is to say, the container will start to work from an image.

There are many Docker images that we can use in our daily work cycle. We can also create our own images and further expand the possibilities of this great application.

However, it’s important to remember that these images can accumulate and occupy significant storage space. Therefore, removing unused Docker images periodically is advisable to maintain an efficient and clutter-free environment.


Docker’s advantages make software deployment much more efficient and convenient than before. Thanks to this, developers will have no problems in knowing how your application will run outside the test environment. On the other hand, the system administrator will not have to struggle with system changes or looking for necessary libraries.

In this tutorial, we showed you the first steps to take with Docker. To unlock the true potential of this great utility, we recommend checking out the official documentation. Happy developing!

The author

Edward S.

Edward is a content editor with years of experience in IT writing, marketing, and Linux system administration. His goal is to encourage readers to establish an impactful online presence. He also really loves dogs, guitars, and everything related to space.