FedoraRHEL Based

How To Install Docker on Fedora 40

Install Docker on Fedora 40

In this tutorial, we will show you how to install Docker on Fedora 40. Docker has revolutionized the way applications are developed, packaged, and deployed across different environments. As a containerization platform, Docker allows you to create lightweight, portable containers that encapsulate your application and its dependencies, ensuring consistent behavior regardless of the underlying infrastructure.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Docker on a Fedora 40.

Prerequisites

Before we dive into the installation process, ensure that you have the following prerequisites in place:

  • A server running one of the following operating systems: Fedora 40.
  • It’s highly recommended to update your Fedora system to the latest version before proceeding with the Docker installation.
  • You will need access to the terminal to execute commands. Fedora provides the Terminal application for this purpose. It can be found in your Applications menu.
  • A stable internet connection to download the necessary packages.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Docker on Fedora 40

Step 1. Update the System.

It’s also crucial to update your Fedora system to the latest packages. This can be done by running the following commands in the terminal:

sudo dnf clean all
sudo dnf update

This command will update your system with the latest available packages, ensuring a smooth and compatible installation process.

Step 2. Installing Docker on Fedora 40.

The first step in installing Docker on Fedora 40 is to set up the Docker repository. This will allow you to install the Docker platform directly from Docker’s official sources, ensuring you receive the latest and most secure version. Begin by installing the required package for managing repositories:

sudo dnf install dnf-plugins-core

Next, add the Docker repository to your Fedora system:

sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo

With the repository in place, you can now install the Docker Engine. The Docker Engine is the core of Docker, responsible for creating and running Docker containers. Install it using the following command:

sudo dnf install docker-ce docker-ce-cli containerd.io

After the installation is complete, you need to start the Docker service:

sudo systemctl start docker

To ensure Docker starts automatically after a system reboot, enable it with:

sudo systemctl enable docker

Step 3. Post-Installation Steps.

For a smoother Docker experience, it’s recommended to add your user to the Docker group. This allows you to run Docker commands without prefixing them with sudo:

sudo usermod -aG docker $(whoami)

You will need to log out and log back in for this change to take effect.

To verify that Docker has been installed correctly, run the following command:

docker run hello-world

This command downloads a test image and runs it in a container. If the installation is successful, you will see a message indicating that your Docker installation is working.

Step 4. Configuring Docker on Fedora 40

  • Docker Configuration Files

Docker’s main configuration file is located at /etc/docker/daemon.json. You can edit this file to customize Docker’s behavior on your system. For instance, you can configure Docker to use different storage and network drivers.

  • Customizing Storage and Networking

To change the storage driver, you might add the following to the daemon.json file:

{
"storage-driver": "overlay2"
}

For network settings, particularly if you are behind a proxy, configure Docker as follows:

{
"proxies": {
"default": {
"httpProxy": "http://<proxy-ip>:<port>",
"httpsProxy": "http://<proxy-ip>:<port>"
}
}
}

Step 5. Common Docker Commands and Their Usage.

Basic Docker Commands:

Understanding basic Docker commands is crucial for managing Docker containers and images effectively:

    • docker pull <image>: Downloads an image from Docker Hub.
    • docker run <image>: Runs a container from an image.
    • docker ps: Lists running containers.
    • docker images: Shows all downloaded images.

Examples:

To run a Nginx web server container, use:

docker run -d -p 8080:80 nginx

This command runs an Nginx container in detached mode and maps port 80 in the container to port 8080 on your host.

Congratulations! You have successfully installed Docker. Thanks for using this tutorial for installing the Docker on your Fedora 40 system. For additional or useful information, we recommend you check the official Docker website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button