How to install Docker using SNAP on Ubuntu Linux

One of the quickest ways to install Docker on Ubuntu Linux, such as 22.04, 20.04, and other versions, is to use the SNAP command; here, we learn how to do so.

Docker doesn’t need an introduction to those who work with containerized-based apps. It is already used globally by hundreds of enterprises and developers. However, installing the latest version of Docker on Ubuntu using the APT package manager requires manually adding an official repository. So, those who don’t want to do that can use the SNAP package manager, also available in Ubuntu, out of the box.

Before following this tutorial, remember that the working directions for Docker installed via Snap will differ because, unlike APT, it installs the application in an isolated environment.

Installing Docker on Ubuntu using SNAP


We don’t need any special requirements to follow this tutorial. However, like installing any other software on Ubuntu, you also need sudo privileges for Snap commands.

Step 1: Update System Packages

Although starting with the system update command on the Terminal is unnecessary because we are about to use the SNAP command line. However, it is good idea to update your packages for better security.

sudo apt update && sudo apt upgrade

Step 2: Install Docker via SNAP

In all modern Ubuntu systems, Snap is a pre-configured package manager for installing many applications in an isolated environment. So, on your command terminal, just run the given command, and you will have the latest version of Docker.

sudo snap install docker

The process could take some time as SNAP downloads all the required files to set up Docker.

Step 3: Create a Docker Group

Unlike a Docker installation, which uses the APT package manager, SNAP will not create a group called ‘docker’ by default. However, we need it to use the Docker command without sudo. Therefore, use the command given to add a group called Docker.

sudo addgroup --system docker

Step 4: Run Docker Command without sudo

After adding the docker group, add your current user so you can use Docker commands without sudo rights.

sudo adduser $USER docker
newgrp docker

Sometimes, even after running the newgrp command, the terminal doesn’t immediately recognize the added user in the group. In such a case, log out and log in again.

Step 5: Disable and Enable Snap Docker

You must also disable and enable Snap’s Docker service to apply your changes.

sudo snap disable docker
sudo snap enable docker

Step 5: Create your first Container

Now, we can use the Docker command to create the required containers; here is an example if you are new to it.

In this example, we download the Debian docker image and create a container using it.

docker pull debian

Create container:

docker create -it --name test debian

Start container

docker start test

Get the command line of the installed container:

docker attach test


In case you think Docker installed using Snap is creating some problems and want to remove it, then here is the command to follow:

sudo snap remove docker

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.