# Docker Installation Guide

If you are **not able to install docker** or for running docker commands you **have to use** `sudo` or even if you downloaded few **images from docker and yet not able to see them in docker desktop**…

Then you are at right place here in this article I will discuss these problems and why it might not be working for you and what’s the solution

I will be focusing on `LINUX` OS how ever if you are in virtual machine or may be trying to run on `wsl` and getting these errors then follow the article you are going to understand root cause of it and will be able to solve it

---

# Docker Installation

There are many ways to install to docker as mentioned on there docs

* Docker Engine
    
* Docker Desktop
    

And many other option that you may want to install but for this article let’s focus on these two

After running commands from there official docs for [installation](https://docs.docker.com/engine/install/ubuntu/) you will find this one command

```bash
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl 
sudo install -m 0755 -d /etc/apt/keyrings 
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
```

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

Now when you run this command you get the **docker-engine for you OS** mark that Point ***for your whole OS not just current user***

Another method docker desktop you can download it from [here](https://docs.docker.com/desktop/)

For Ubuntu Commands are

```bash
sudo apt install gnome-terminal
```

```bash
sudo apt-get update
sudo apt-get install ./docker-desktop-amd64.deb
```

> You may get error like below at end and it’s normal just ignore it
> 
> ```bash
> N: Download is performed unsandboxed as root, as file '/home/user/Downloads/docker-desktop.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
> ```

Now Start you docker

```bash
systemctl --user start docker-desktop
```

# Why `sudo` everytime ?

So when you download docker engine it’s for you Whole OS and If it is for you OS not just current user then to control it you must have to give permission to read and write at OS level with `sudo` keyword and when you install `Docker Desktop` it gets downloaded on user level.

And now as we know every image downloaded from docker must be visible on the Docker Desktop but you may end up with “***not able to see my downloaded images in my Docker Desktop”*** yep because your docker is running on OS level not on User level

Now some of you say We are able to run with just `docker` and then our images are seen in Docker Desktop but when we run commands with `sudo docker` our docker images can’t be seen in docker desktop and may be you will not be able to run many commands with just docker and you might have to use `sudo docker`

So I experienced the same problem, tried many ways to solve the issue but failed again and again. One article which was most suitable and almost solved the problem is An [article from Andrey Byhalenko](https://medium.com/devops-technical-notes-and-manuals/how-to-run-docker-commands-without-sudo-28019814198f)

But still not able to get the solution that satisfied me and that `sudo` key word altogether and then I got to know about those contexts as mentioned earlier OS context for docker engine ( for which have to use `sudo` ) and other context that comes with docker desktop as it is not just a software it’s a bundle of complete docker ecosystem on user level not os level

means when you use `sudo docker` context for docker images are switched to OS level and when you use `docker` context remains docker desktop

Multiple context multiple ways and lot’s of confusion

So by giving it a thought I ended up like why do I even need 2 contexts of docker ?

So just remove one context that could be any one

* If you are fine working with sudo and do not need graphical interface and can work with docker cli go for OS level context or docker engine
    
* If you think that GUI is important can’t do it with CLI and want to live without `sudo docker` command just uninstall docker engine and install docker desktop
    

# If you are going with Docker Desktop

You have to run commands after installation of docker desktop

```bash
systemctl --user status docker-desktop
```

It may prompt

```bash
○ docker-desktop.service - Docker Desktop
     Loaded: loaded (/usr/lib/systemd/user/docker-desktop.service; disabled; pr>
     Active: inactive (dead)
```

So what it says? it says that docker is not running currently and will not be running automatically after you login to you account ( as it’s an user level context so need to be user specific ) so you have to start docker desktop manually whenever you want to use it.

And if you think no I want my docker to start just after login to my account then run commands

```bash
systemctl --user start docker-desktop
systemctl --user enable docker-desktop
```

And now if you run command

```bash
systemctl --user status docker-desktop
```

You will get something like

```bash
● docker-desktop.service - Docker Desktop
     Loaded: loaded (/usr/lib/systemd/user/docker-desktop.service; enabled; pre>
     Active: active (running) since Wed 2025-05-07 06:47:28 IST; 1min 18s ago
   Main PID: 45142 (com.docker.back)
      Tasks: 149 (limit: 9289)
     Memory: 2.9G (peak: 2.9G)
        CPU: 2min 4.885s
```

So now you system will start docker every time you login into that context

---

And yeah that’s the process that i thought was easy and i ended up working with docker easily

User level context is amazing if you only have one user account on you linux OS

Hope It solves you problem

---
