Hostomy Blog

How to Install Docker on Ubuntu 24.04

Dec 03, 2024

By Rahul Mukati

Rahul Mukati
How to Install Docker on Ubuntu 24.04

Docker is a game-changer in the tech world, enabling developers to create, deploy, and run applications in lightweight, portable containers. Whether you're a seasoned professional or a curious beginner, setting up Docker on Ubuntu 24.04 is simpler than you might think. This guide will take you through the process step by step.

If you don't already have a server, consider getting a cloud server from Hostomy to get started with Docker in a reliable environment.

Why Docker?

Docker lets you isolate your applications, ensuring they run consistently across different systems. This means no more "it works on my machine" moments! Plus, its lightweight nature and portability make it ideal for modern development and deployment practices.

Pre-requisites

Before diving in, make sure you have:

  • A server running Ubuntu 24.04. If you need one, Hostomy Cloud Servers provide scalable, affordable solutions.
  • sudo access to your server.
  • Basic familiarity with the Linux terminal.

Step 1: Update Your Server

To begin, ensure your server is up-to-date. Run the following commands:

sudo apt update
sudo apt upgrade -y  

This updates the package list and installs the latest available versions of the packages on your server.

Step 2: Install Required Packages

Docker needs a few essential packages for smooth installation. Install them using the command:

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

These packages allow your system to securely fetch Docker's repositories.

Step 3: Add Docker’s GPG Key and Repository

Next, add Docker's official GPG key to verify downloads:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Then, add the Docker repository to your system:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 4: Install Docker

Update the package list again to include the Docker repository:

sudo apt update

Now, install Docker Engine:

sudo apt install -y docker-ce docker-ce-cli containerd.io

Step 5: Start and Enable Docker

After installation, start the Docker service and ensure it runs on boot:

sudo systemctl start docker
sudo systemctl enable docker

You can verify that Docker is running with:

sudo systemctl status docker

Step 6: Test Docker Installation

Check if Docker was installed correctly by running a test container:

sudo docker run hello-world

This command pulls a test image and runs it in a container. If everything is set up properly, you'll see a "Hello from Docker!" message.

Optional: Manage Docker as a Non-Root User

To use Docker without sudo, add your user to the Docker group:

sudo usermod -aG docker $USER

Log out and log back in for the changes to take effect.

Next Steps

With Docker installed, you’re ready to explore its powerful features. Here are some ideas:

  • Launch a web server using Docker.
  • Experiment with Docker Compose to manage multi-container applications.
  • Try building your first custom Docker image.

Why Hostomy for Your Cloud Server?

Docker thrives in a cloud environment, offering scalability and flexibility. At Hostomy, we provide reliable cloud servers perfect for deploying your Docker applications.

Ready to unleash the potential of Docker? Set up your cloud server with Hostomy today and start building like a pro! 🚀