亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
Table of Contents
Why Use Docker to Deploy Services in Linux
Install Docker on Ubuntu
Install Docker on Debian
Install Docker on Fedora
Install Docker on Red Hat Enterprise Linux
Install Docker on Arch Linux
Deploying Your First Docker Container
Using Docker Compose to Run Your Container
Home Computer Tutorials Computer Knowledge How to Install Docker in Linux - Make Tech Easier

How to Install Docker in Linux - Make Tech Easier

Jul 27, 2025 am 01:21 AM

Docker is a powerful containerization platform that allows anyone to deploy and release complex programs just like regular apps. This makes it attractive to users who want to run online services but don’t want to deal with the headache of managing dependencies and config files. This article will show you how to install Docker and Docker Compose on some of the most popular Linux distros today.

Table of Contents

  • Why Use Docker to Deploy Services in Linux
  • Install Docker on Ubuntu
  • Install Docker on Debian
  • Install Docker on Fedora
  • Install Docker on Red Hat Enterprise Linux
  • Install Docker on Arch Linux
  • Deploying Your First Docker Container

Why Use Docker to Deploy Services in Linux

Container platforms such as Docker are a popular way to install services on your Linux machine. They allow you to easily isolate complex software into portable units which, in turn, improves the security of your server.

How to Install Docker in Linux - Make Tech Easier

One powerful feature of Docker is that once a container works in one distro, making it work in others is a relatively straightforward process. This is because Docker abstracts the differences between these Linux distros making it compatible with little modifications on the container.

Docker also simplifies service management compared to non-containerized deployments. Originally, when something breaks in the system, you’ll have to reinstall and reconfigure every service on that machine. With Docker, you just need to copy the config files to another machine, start the service and you can immediately continue where you left off.

Install Docker on Ubuntu

Start by checking the key fingerprint of the official Docker project’s public key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --show-keys --with-fingerprint

At the moment, the fingerprint for the Docker project’s signing key is: 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

How to Install Docker in Linux - Make Tech Easier

That said, this key may change in the future. Check Docker’s official website to see if they match. It’s important to cross-reference this to ensure that the software you’re installing is legitimate.

Once you confirm the validity of the signing key, download and save it to your “/etc/apt/keyrings” folder:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Ensure that the permission bits of the keyfile is correct:

sudo chmod a r /etc/apt/keyrings/docker.gpg

Create a new repository file for the Docker project:

sudo nano /etc/apt/sources.list.d/docker.list

Paste the following line of code inside your new repository file:

deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu noble stable

Save your new repository file, then update your system’s package repositories:

sudo apt update && sudo apt upgrade

Install the core Docker packages along with the Docker Compose plugin. These will allow you to deploy Docker applications and orchestrate them properly:

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

Most docker commands need to be prefixed with sudo. If you want to avoid having to type your password every time, add your user account to the “docker” group:

sudo adduser YOUR-CURRENT-USERNAME docker

Log out of your graphical user interface and log back in. Now you can use commands such as docker ps instead of sudo docker ps.

Tip: you can also disable password verification in sudo by tweaking the sudoers file.

Install Docker on Debian

Since Debian is the upstream Linux distro for Ubuntu, it also uses apt for managing its packages and repositories. This means that the steps are almost similar to Ubuntu barring a handful of Debian-specific GPG keys and repository links.

To start, fetch the Docker repository’s signing key from the Docker project:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Note: Just like with Ubuntu, you also should confirm the GPG fingerprint of the Debian Docker repository. At the moment, it’s: 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

Create the apt repository file for the Docker project:

sudo nano /etc/apt/sources.list.d/docker.list

Paste the following line of code inside the repository file:

deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable

Refresh the machine’s repository listings and update your Debian system:

sudo apt update && sudo apt upgrade

Fetch and install the Docker core packages and the Docker Compose plugin:

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

Add your user account to the “docker” group:

sudo usermod -aG docker YOUR-USERNAME

Restart your Debian machine to apply your new settings, then run the following command to test if Docker install is working properly:

docker -v

How to Install Docker in Linux - Make Tech Easier

Install Docker on Fedora

To install Docker and Docker Compose on Fedora, first obtain the management program for dnf:

sudo dnf install dnf-plugins-core

Fetch the repository details for Docker and commit it to your dnf installation:

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

Install the Docker, Docker Compose, and their dependencies:

sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Confirm that the fingerprint for the Docker repository is: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35. Type “y”, then press Enter to continue the installation process:

How to Install Docker in Linux - Make Tech Easier

Enable and start the Docker systemd service:

sudo systemctl enable --now docker.service

Make sure that your current user account is in the “docker” user group:

sudo usermod -aG docker YOUR-USERNAME

Log out and log back in to your graphical user interface, then test your Docker installation by running the “Hello, world!” container:

docker run hello-world

How to Install Docker in Linux - Make Tech Easier

Good to know: learn how Docker containers simplify application deployment by self-hosting your own bit.ly service with Shlink.

Install Docker on Red Hat Enterprise Linux

Red Hat Enterprise Linux (RHEL) is a stable, long-term support downstream distro of Fedora. Unlike its upstream, RHEL provides a consistent and rock-solid environment where you can reliably run your applications. This makes it a great system for deploying programs that you want to run with little to no interruptions.

Start by fetching the repository file for the Docker project:

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

Obtain and install Docker, Docker Compose, and their dependencies:

sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

You can also specify the version of Docker that you want to run on your system. To do this, list the available versions of Docker for your machine:

dnf list docker-ce --showduplicates

Scroll through the list of available versions, then copy the version number that you want to install.

How to Install Docker in Linux - Make Tech Easier

Paste the following command to your terminal, then replace the value of the version variable with your version number:

version="YOUR-VERSION-NUMBER-HERE"

Install the specific version of Docker in your system:

sudo dnf install docker-ce-3:$version docker-ce-cli-1:$version containerd.io docker-buildx-plugin docker-compose-plugin

Enable and run the Docker service using systemctl:

sudo systemctl enable --now docker.service

Add your current user to the docker user group:

sudo useradd -aG docker YOUR-USERNAME

Test if Docker is working properly by running docker --version to list its version number.

How to Install Docker in Linux - Make Tech Easier

Install Docker on Arch Linux

Arch Linux already includes Docker and Docker Compose in its community repositories. This makes installing both as simple as running pacman:

sudo pacman -S docker docker-compose containerd docker-buildx

How to Install Docker in Linux - Make Tech Easier

Add the current user account to the Docker group:

sudo usermod -aG docker YOUR-USERNAME

Reboot your machine to reload your system and start the Docker daemon.

Enable Docker service to automatically start at boot and run it in the current session:

sudo systemctl enable --now docker.service

Test if Docker is working properly by running the “Hello, world” container:

docker run hello-world

How to Install Docker in Linux - Make Tech Easier

Deploying Your First Docker Container

With Docker up and running on your machine, you can now use the platform to obtain various applications and services on your system. The quickest way to start using Docker is to look for prebuilt containers for popular applications.

Note: While Docker uses the same commands to build and run different apps, every container has its unique requirements for them to work. As such, you should always consult with the container’s documentation and an appropriate guide before pulling a Docker image.

That said, start by going to Docker Hub and search for an app that you want to install. For this, I will use the Nginx Docker container since I want to serve a basic static website.

How to Install Docker in Linux - Make Tech Easier

Go back to your terminal session, then create a directory for your Docker container:

mkdir ./docker-nginx && cd ./docker-nginx

Copy your static website inside the Docker directory:

cp -r ~/html-site ./docker-nginx

Create a Dockerfile inside your new directory using your favorite text editor:

nano ./Dockerfile

Paste the following lines of code inside your Dockerfile. This will load the Nginx image and copy the static website from my “html-site” folder to the “html” folder inside the container.

FROM nginx<br>COPY html-site /usr/share/nginx/html

Save your Dockerfile, then build the Nginx Docker container:

docker build -t static-nginx .

Run the newly built Docker container using the run subcommand:

docker run --name my-nginx-website --publish 8080:80 -d static-nginx

Using Docker Compose to Run Your Container

Aside from running directly in the command line, you can also use Docker Compose to start your container. This is a way to create reproducible Docker setups which can be helpful in more complex deployments.

Create a “docker-compose.yml” file inside your Docker directory:

nano docker-compose.yml

Paste the following block of code inside your Compose file:

services:<br>  nginx:<br>    container_name: my-nginx-website<br>    build:<br>      context: .<br>      dockerfile: Dockerfile<br>    ports:<br>      - 8080:80

Save your “docker-compose.yml” file, then start your Docker container:

docker compose up -d

Test if your new website is working properly by visiting “l(fā)ocalhost:8080” using your web browser.

How to Install Docker in Linux - Make Tech Easier

Learning the basics of Docker, installing it to your Linux system, and running a basic Dockerized web server are just some of what you can do with this wonderful container platform. Explore the deep world of self-hosting web services with Docker by deploying your own online RSS reader with Tiny Tiny RSS.

Image credit: Mohammad Rahmani via Unsplash. All alterations and screenshots by Ramces Red.

The above is the detailed content of How to Install Docker in Linux - Make Tech Easier. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

A Guide on Ubisoft Connect Download, Install, and Reinstall - MiniTool A Guide on Ubisoft Connect Download, Install, and Reinstall - MiniTool Jul 02, 2025 am 12:18 AM

If you want to play Ubisoft Connect games, you can choose to download this app and install it on your device. This post from php.cn guides on Ubisoft Connect download and install for PC, Android, and iOS. Besides, if you run into Ubisoft Connect down

Google Translate Picture | Translate Text in Images - MiniTool Google Translate Picture | Translate Text in Images - MiniTool Jul 12, 2025 am 12:57 AM

This Google translate picture guide shows you how to translate text from an image. If you are looking for more computer tips and solutions, you can visit php.cn Software official website where you can also find some useful computer tools like php.cn

How to Install Device Drivers Manually on Windows 11/10? - MiniTool How to Install Device Drivers Manually on Windows 11/10? - MiniTool Jul 06, 2025 am 12:15 AM

If your Windows 11/10 computer doesn’t automatically the latest versions of device drivers, you will need to manually install them. In this post, php.cn Software will show you 3 different methods to manually install drivers on your device.

Fix Error Code 'SSL_Error_Handshake_Failure_Alert” in Browsers - MiniTool Fix Error Code 'SSL_Error_Handshake_Failure_Alert” in Browsers - MiniTool Jul 02, 2025 am 12:23 AM

The error code “ssl_error_handshake_failure_alert” often happens when you are trying to access some sites. These complicated codes may make you overwhelmed and confused. But you don’t need to worry about it. It’s reversible. Just follow this guide on

9 Ways – How to Open Task Scheduler in Windows 10/Windows 11… - MiniTool 9 Ways – How to Open Task Scheduler in Windows 10/Windows 11… - MiniTool Jul 03, 2025 am 12:28 AM

This post summarized on php.cn official website mainly introduces you nine ways to open Task Scheduler in Windows 10 together with the latest Windows 11. Generally, these methods are similar in both systems with just a little difference.

Guide - iTunes Download, Install, & Reinstall in Windows 11/10 - MiniTool Guide - iTunes Download, Install, & Reinstall in Windows 11/10 - MiniTool Jul 02, 2025 am 12:15 AM

What is iTunes? How to download iTunes for Windows 11 or 10? How to install iTunes to a PC to manage your entire media collection in one place? After reading the guide on iTunes download Windows 11/10, install and use, you know much information given

Guide: Stop File Explorer From Showing External Drives Twice Guide: Stop File Explorer From Showing External Drives Twice Jul 02, 2025 am 12:25 AM

Have you found that your external hard drives show up twice in the navigation pane of File Explorer? Do you know how to stop File Explorer from showing external drives twice? Now you can get detailed instructions from this post on php.cn.

Guide - How to Update Visual Studio to a New Version in Windows - MiniTool Guide - How to Update Visual Studio to a New Version in Windows - MiniTool Jul 02, 2025 am 12:21 AM

How to update Visual Studio 2022/2019/2017/2015/2013 to a new version to gain a better experience? It is a simple way and you can follow some ways given by php.cn to easily do the update operation.

See all articles