Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Docker in CentOS 8.4

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to install Docker in CentOS 8.4". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

System requirements:

Docker supports the 64-bit version of CentOS 7 Compact 8, and requires that the kernel version be no less than 3.10.

Centos-extrasrepository needs to be enabled. In CentOS 7, this warehouse is enabled by default. If you have previously disabled it, you need to re-enable it.

CentOS 7 meets the minimum kernel requirements, but due to the lower kernel version, some features (such as overlay2 storage layer drivers) cannot be used, and some functions may be unstable.

Installation environment:

The main purpose of this article is to install Docker in the Liunx operating system CentOS8.4. Before installing it, we can check our own system version and use the command: lsb_release-a (as shown in the following figure).

Note: do not directly use the yum command to install Docker. Docker YUM without configuring the Docker source.

Uninstall the old version:

The package name of the old version of Docker in CentOS is docker or docker-engine. If you installed an old version of Docker on your previous Linux CentOS system, you need to uninstall the old version of Docker and its related dependencies first, execute the following command:

Sudo yum remove docker\ docker-client\ docker-client-latest\ docker-common\ docker-latest\ docker-latest-logrotate\ docker-logrotate\ docker-selinux\ docker-engine-selinux\ docker-engine

Because my system has just been installed, the above command prompt did not find the package that needs to be removed!

If yum reports that these packages are not installed, that's fine.

Note: the contents of the / var/lib/docker/ directory, including images, containers, volume groups, networks, and other files will be retained. Docker CE's new package is called docker-ce.

What exactly does yum do?

Brief description: yum is called package manager, which is mainly used to solve four problems: download, dependency, installation and uninstall.

Details: https://blog.csdn.net/weixin_43202123/article/details/119948927

Install using yum:

Execute the following command to install the dependency package and some necessary system tools:

Sudo yum install-y yum-utils device-mapper-persistent-data lvm2 configures yum stable mirror source:

Due to domestic network reasons, it is recommended to use the Docker CE image origin server provided by Ali Cloud!

Sudo yum-config-manager-- add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Official image source address:

# official Source # sudo yum-config-manager-- add-repo https://download.docker.com/linux/centos/docker-ce.repo installs Docker

Update the yum software source cache and install docker-ce (just yes all the way).

Sudo yum install docker-ce docker-ce-cli containerd.io

The following are the dependencies for successful installation:

Check the successfully installed version of docker: docker-v

CentOS8 extra Settin

Because the CentOS8 firewall uses nftables, Docker does not yet support nftables.

First of all, let's check the status of the firewall. If the state of the firewall is on, we do the following:

Systemctl status firewalld

We can use iptables with the following settings: change / etc/firewalld/firewalld.conf

# FirewallBackend=nftablesFirewallBackend=iptables

Or execute the following command:

Firewall-cmd-- permanent-- zone=trusted-- add-interface=docker0 firewall-cmd-- reload enables the Docker service:

Execute sudo service docker start command to open Docker service prompt exception: Redirecting to / bin/systemctl start docker.service

To see the exception is to execute the relevant commands of systemctl, because different distributions of Linux have different commands to open the Docker service.

Sudo systemctl enable dockersudo systemctl start docker

Finally check the running status of docker

Systemctl status docker

Start the Docker daemon:

Official tutorial: https://docs.docker.com/config/daemon/systemd/

Manual start

After installing Docker, you need to start the Docker daemon. Most Linux distributions are used for systemctl startup services.

Sudo systemctl start docker starts automatically when the system starts

If you want Docker to start at startup, see configure Docker to start at startup.

Docker basic commands:

Start docker:systemctl start docker

Stop docker:systemctl stop docker

Restart docker:systemctl restart docker

View docker status: systemctl status docker

Boot: systemctl enable docker

Current system docker information: docker info

List all the containers: docker ps-a

Stop container: docker start container ID or container name

Close the container directly: docker kill container ID or container name

Restart container: docker restart container ID or container name

Delete container: docker rm container ID or container name

View image: docker image ls

More Command search (recommended): Docker Command online Quick search Manual

Test whether Docker is installed correctly

First of all, let's enter whether docker run hello-world will appear the prompt shown in the following figure. If an error occurs, there may be a problem with the configuration of the environment.

Note: this command will cause Docker to pull the image of hello-world from the official repository locally (if the image does not exist locally) and automatically instantiate the container.

Unable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-world2db29710123e: Pull completeDigest: sha256:37a0b92b08d4919615c3ee023f7ddb068d12b8387475d64c622ac30f45c29c51Status: Downloaded newer image for hello-world:latest Hello from docking this message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $docker run-it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/

View hello-World images and containers:

This is the end of "how to install Docker in CentOS 8.4". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report