Using Ubuntu GNOME Desktop (GUI)? Click here

Installing Docker using the Command Line:

Certainly! Installing Docker on Ubuntu Server 22.04 without a graphical user interface (GUI) is a straightforward process. Docker allows you to automate the deployment of applications inside lightweight, portable containers. Follow these steps to install Docker on your Ubuntu Server:

Step 1: Update Package Lists

Before installing any software, it’s good practice to ensure your package lists are up-to-date and we have deleted any old docker packages. Open a terminal and run:

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

sudo apt update

Step 2: Install Necessary Dependencies

Make sure that the required packages are installed:

sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo apt install apt-transport-https ca-certificates curl software-properties-common

Step 3: Add Docker’s GPG Key

Docker packages are signed with a GPG key for verification. Add the Docker GPG key using the following command:

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

Step 4: Set Up the Docker Stable Repository

Add the Docker stable repository to your system:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] 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

Step 5: Install Docker

Update the package lists again and install Docker:

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

Step 6: Verify Docker Installation

Check if Docker is installed successfully by running the following command:

sudo docker --version

You should see information about the installed Docker version.

Step 7: Manage Docker Without sudo (Optional)

By default, Docker commands require sudo privileges. If you want to run Docker without using sudo, add your user to the docker group:

sudo usermod -aG docker $USER

Log out and log back in or restart your system to apply the group changes.

Step 8: Test Docker with a Hello World Container

Run a simple container to ensure everything is working correctly:

docker run hello-world

If successful, you’ll see a message indicating that your Docker installation is working.

Congratulations! You’ve successfully installed Docker on Ubuntu Server 22.04 without a GUI. You can now start using Docker to containerize and deploy your applications.

Using Ubuntu GNOME Desktop:

In this tutorial, we will walk you through the process of installing Docker Desktop and Docker Engine on Ubuntu 22.04.

Step 1: Install Docker Engine

Before installing Docker Desktop, we need to install Docker Engine first. On the left navigation bar, select “Docker Engine” and choose “Install”. From there, select “Ubuntu” and follow the instructions.

Make sure you do not have any old versions of Docker installed. If you do, uninstall them. Then, copy and paste all of the commands provided one after the other to install Docker Engine.

Verify that Docker Engine was installed correctly by running the image provided. If you see “Hello from Docker,” Docker Engine was installed correctly.

Step 2: Download Docker Desktop

Head over to docs.docker.com. From there, select the “Download and Install” option and choose Docker Desktop for Linux. If you are using Ubuntu GNOME Desktop, download the DEB file by navigating to Install Docker Desktop -> Install Docker on Linux Distro -> Ubuntu and click DEB to download the file. If you are on Windows, you can still download the file, you’ll just need to use WinSCP or a tool like it to move the deb file from your Windows machine to the Ubuntu machine.

Step 3: Install Docker Desktop

After installing Docker Engine, we can now install Docker Desktop. Navigate to the following link and follow the instructions starting with “Prerequisites”. (https://docs.docker.com/desktop/install/ubuntu/)

Use the “apt install” command to install Docker Desktop. Run the command from the folder where you downloaded the .deb file to. As a prerequisite, it will also download qemu and kvm.

Once the installation is complete, open Docker Desktop from the Ubuntu application menu.

Step 4: Run Containers

Now that Docker Desktop is installed, let’s run a sample container. Copy the line provided and paste it into your terminal. The docker image will be downloaded, and the container will run.

docker run -d -p 80:80 docker/getting-started

To interact with Ubuntu from the terminal, launch the terminal and run the ubuntu container.

You can also run an Nginx container and select the directory you want to publish. Once the image is pulled, a container will be created. You can see all the images you currently have on your system in the Images tab.

In conclusion, Docker Desktop makes it easy to manage and deploy Docker containers on your desktop. With this tutorial, you can now install Docker Desktop on Ubuntu 22.04 and start running containers.