How to install docker engine on ubuntu vps serverThis article provides a guide for how to install Docker Engine on Ubuntu VPS server.

What is Docker?

Docker is an application that utilizes OS-level virtualization to provide software in bundles called containers. While you can run Docker on any VPS, Ubuntu remains its most popular OS of choice.

Containers provide an application’s code, dependencies, libraries, and configuration files with their own secure environment, reducing the chance of any glitch or bug impacting system performance negatively.

Docker is an invaluable tool that helps developers speed up application development and deployment processes.

By packaging applications into lightweight self-contained packages called containers containing code, libraries, runtime components, system settings and dependencies; Docker then allows applications to run across various platforms including Linux virtual machines with ease and consistency across platforms and environments.

In addition, it ensures consistent security practices throughout deployments for consistent application deployment across servers and environments.

How to Install Docker Engine on Ubuntu VPS Server

The following steps will show you how to install Docker Engine on Ubuntu VPS Server:

Docker System Requirements

Make sure your Ubuntu VPS server meets the following Docker system requirements:

  • OS: Linux Ubuntu (Recommended: Ubuntu 22.04 LTS)
  • Memory: 512MB RAM (2GB Recommended)
  • A sufficient amount of disk and CPU (dependent upon the applications)
  • It only works on a 64-bit Linux installation.
  • It requires Linux kernel version 3.10 or higher.

Save 50% off ubuntu vps server hosting

1. Installing Docker Engine

To install Docker, a 64-bit Ubuntu system with the docker package installed and an administrator user. With these requirements in place, installation should be relatively straightforward.

First, login to the server via SSH. Then run this command to remove outdated versions:

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

Once Docker is operational, you can add other images to your system by opening up a terminal and using this command:

Docker command line prompts you to provide information on both the name of image to be added as well as its location. After providing that data, click enter.

When you’re ready to install a new image, use the docker images command to list all available local images and select one to download and use.

2. Installing Docker’s GPG Key

GPG Key for Docker Updates/Builds on Ubuntu Server It is necessary to install Docker’s GPG key for secure updates/build on an Ubuntu Server in order for it to function effectively; you can do this by running this command:

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

This command will update and add the Docker repository to your apt cache, verifying its validity with an output that should indicate successful installation of Docker.

To enable Docker commands without prepending sudo, it’s essential that your user be added to the Docker group. You can do this using this command:

sudo groupadd docker
sudo usermod -aG docker $USER

Log out and log back in so that your group membership is re-evaluated.

Once you’ve added your user to the Docker group, you can verify their full privileges by logging in and running docker commands – for instance launching the “hello-world” image should result in an output showing success messages.

Docker comes equipped with its own companion program called docker compose that streamlines multi-container applications by making their management simpler. You can start, stop and manage several containers all from one command – making this tool ideal for users wanting to streamline their workflow without complicated scripting and multiple command lines.

Docker provides networking support in a distributed environment. It can create private networks between hosts and connect multiple networks using overlays – making it simple to scale your apps onto multiple servers while maintaining high-performance environments for them.

Docker can be downloaded directly from its official website or distributed repositories like Ubuntu’s. Yum can be used to install it on Debian-based systems and RPM-based ones (CentOS, Fedora and SLES) respectively using Debian package management or CentOS RPM repositories respectively; or for automated convenience scripts you could try Automated Convenience Installs instead.

3. Installing Docker’s Stable Repository

Now, you should install the latest stable version of Docker by running the following command:

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

Verify that the Docker Engine installation was successful by running the hello-world image:

sudo docker run hello-world

Docker will then access Docker Hub and pull the hello-world image, before running it in a container for execution – the output you see will indicate whether or not Docker is functioning as expected.

Before starting, ensure your Ubuntu server meets the minimum requirements for installing Docker, such as having an account with sudo privileges and stable internet connectivity. In addition, being familiar with basic package management and dependency resolution on Ubuntu may prove helpful if issues arise while following these instructions.

After downloading and installing yum-utils, which enables you to add the Docker stable repository, execute this command: [Add Repository to System]. With your new repository established, use yum to install or upgrade Docker using this method.

If you have a virtual machine (VM), Docker Desktop offers an easy way to manage containers. This feature can help maximize platform use when combined with Kubernetes tools; however, be mindful that using Docker Desktop uses virtualization which could negatively impact server performance.

Docker can also be installed from an RPM package, which enables manual installations and upgrades – an approach suitable for air-gapped systems or test/development environments.

Once Docker is installed on your Ubuntu server, you can begin using it to build and launch containers of your own. To do so, log in as normal before entering this command to launch the service:

If the service has started successfully, a message will indicate its functionality as well as display which version of Docker has been installed.

To run Docker commands, administrator privileges or prefixed with sudo are needed to execute commands. To run it as non-root user, add their user to the docker group.

4. Configure Docker to Start on Boot

To configure Docker to start on boot with systemd, issue the following commands:

sudo systemctl enable docker.service
sudo systemctl enable containerd.service

For optimal Docker installation, it is crucial that post-installation steps be completed. This should include adding yourself to the docker group, enabling logging and storage management and creating the docker service on your server. Furthermore, ensure your firewall settings allow Docker to function appropriately as it relies on various ports in order to operate efficiently.

Once completed, it’s time to launch the Docker service on your server. Debian-based distributions, such as Ubuntu, automatically launch it; RPM-based systems like CentOS, Fedora and SLES need to manually initiate it. It is also possible to configure it so it launches when your server boots up if desired.

Lastly, to test that everything is functioning as expected you could run a test image to verify its operation:

docker run hello-world

Conclusion

You now know how to install Docker Engine on Ubuntu VPS Server!

Launch ubuntu vps from $2. 49/mo!

Avatar of editorial staff

Editorial Staff

Rad Web Hosting is a leading provider of web hosting, Cloud VPS, and Dedicated Servers in Dallas, TX and Phoenix, AZ.
lg