Support Online
Skip to main content

Installing and Using Docker on Ubuntu

What will you learn in this guide?

In this guide, you will learn how to install the latest version of Docker on Ubuntu.
You will understand the concepts of container and image in a practical way.
You will learn to share the images you create via Docker Hub.

🧠 Technical Analysis and Summary

This guide explains the installation and basic use of Docker on the Ubuntu operating system.
The goal is to run applications within isolated containers.
Steps; It covers installation, authorization, image management and Docker Hub integration.


1️⃣ Docker Installation

The Docker version in Ubuntu's default repository may be out of date.
Therefore, we will add the official Docker repository.

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
  • Updates system packages and provides secure downloads over HTTPS.


curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
  • Adds Docker's official repository and authentication key.


sudo apt update
sudo apt install docker-ce
  • Installs the Docker engine.


sudo systemctl status docker
  • Verifies that the Docker service is running.

2️⃣ Running Docker Commands Without Sudo (Optional)

  1. To avoid using sudo all the time, you can add the user to the docker group.

sudo usermod -aG docker ${USER}
  • Grants Docker authority to the user.

🔔 Log out and log in again for the change to take effect.


3️⃣ Working with Docker Images and Containers

  1. In Docker, everything starts from an image.

docker run hello-world
  • Tests that Docker is working correctly.


docker run -it ubuntu
  • Starts the Ubuntu container in interactive mode.

You can do an example installation while inside the container:


apt update
apt install nodejs -y
node -v
  • Installs Node.js into the container and verifies the version.


exit
  • Takes it out of the container.

4️⃣ Creating and Sharing Your Own Docker Image

  1. You can make changes you make to a container permanent.

docker commit -m "Node.js eklendi" -a "Yazar Adi" konteyner_id kullanici_adin/yeni-imaj
  • Creates a new Docker image from the existing container.


docker login -u kullanici_adin
docker push kullanici_adin/yeni-imaj
  • Uploads the image to Docker Hub.

❓ Frequently Asked Questions (FAQ)

1. What is the difference between Docker and a virtual machine? Virtual machines carry a full operating system. Docker containers share the kernel.

2. Should Docker Desktop be used on the server? No. Docker CE is recommended for servers.

3. What is the difference between Image and Container? Image is a pattern. Container is the application that runs from that mold.


🛠️ Troubleshooting

ErrorPossible CauseSolution
command not foundDocker is not installedRun the command sudo apt install docker-ce
permission deniedNo authorizationAdd user to group docker
GPG errorKey faultyRepeat the step of adding GPG

🎯 Result

Docker is the foundation of modern software infrastructure. You can create consistent and scalable environments by installing Docker on Ubuntu. You can immediately try your high-performance Docker projects on the GenixNode infrastructure 🚀