contos安装docker

一、Docker安装

1、安装gcc

yum -y install gcc
yum -y install gcc-c++

详细安装如下

[root@localhost yum.repos.d]# yum -y install gcc
Last metadata expiration check: 0:01:42 ago on Tue 08 Nov 2022 02:41:44 PM CST.
Package gcc-8.5.0-3.el8.x86_64 is already installed.
Dependencies resolved.
================================================================================
 Package         Architecture   Version                 Repository         Size
================================================================================
Upgrading:
 cpp             x86_64         8.5.0-4.el8_5           AppStream          10 M
 gcc             x86_64         8.5.0-4.el8_5           AppStream          23 M
 libgcc          x86_64         8.5.0-4.el8_5           base               79 k
 libgomp         x86_64         8.5.0-4.el8_5           base              206 k
​
Transaction Summary
================================================================================
Upgrade  4 Packages
​
Total download size: 34 M
Downloading Packages:
(1/4): libgcc-8.5.0-4.el8_5.x86_64.rpm          116 kB/s |  79 kB     00:00
(2/4): libgomp-8.5.0-4.el8_5.x86_64.rpm         162 kB/s | 206 kB     00:01
(3/4): cpp-8.5.0-4.el8_5.x86_64.rpm             236 kB/s |  10 MB     00:45
(4/4): gcc-8.5.0-4.el8_5.x86_64.rpm             245 kB/s |  23 MB     01:38
--------------------------------------------------------------------------------
Total                                           354 kB/s |  34 MB     01:38
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Upgrading        : cpp-8.5.0-4.el8_5.x86_64                               1/8
  Running scriptlet: cpp-8.5.0-4.el8_5.x86_64                               1/8
  Upgrading        : libgomp-8.5.0-4.el8_5.x86_64                           2/8
  Running scriptlet: libgomp-8.5.0-4.el8_5.x86_64                           2/8
  Upgrading        : libgcc-8.5.0-4.el8_5.x86_64                            3/8
  Running scriptlet: libgcc-8.5.0-4.el8_5.x86_64                            3/8
  Upgrading        : gcc-8.5.0-4.el8_5.x86_64                               4/8
  Running scriptlet: gcc-8.5.0-4.el8_5.x86_64                               4/8
  Running scriptlet: gcc-8.5.0-3.el8.x86_64                                 5/8
  Cleanup          : gcc-8.5.0-3.el8.x86_64                                 5/8
  Running scriptlet: cpp-8.5.0-3.el8.x86_64                                 6/8
  Cleanup          : cpp-8.5.0-3.el8.x86_64                                 6/8
  Cleanup          : libgcc-8.5.0-3.el8.x86_64                              7/8
  Running scriptlet: libgcc-8.5.0-3.el8.x86_64                              7/8
  Running scriptlet: libgomp-8.5.0-3.el8.x86_64                             8/8
  Cleanup          : libgomp-8.5.0-3.el8.x86_64                             8/8
  Running scriptlet: libgomp-8.5.0-3.el8.x86_64                             8/8
  Verifying        : libgcc-8.5.0-4.el8_5.x86_64                            1/8
  Verifying        : libgcc-8.5.0-3.el8.x86_64                              2/8
  Verifying        : libgomp-8.5.0-4.el8_5.x86_64                           3/8
  Verifying        : libgomp-8.5.0-3.el8.x86_64                             4/8
  Verifying        : cpp-8.5.0-4.el8_5.x86_64                               5/8
  Verifying        : cpp-8.5.0-3.el8.x86_64                                 6/8
  Verifying        : gcc-8.5.0-4.el8_5.x86_64                               7/8
  Verifying        : gcc-8.5.0-3.el8.x86_64                                 8/8
​
Upgraded:
  cpp-8.5.0-4.el8_5.x86_64               gcc-8.5.0-4.el8_5.x86_64
  libgcc-8.5.0-4.el8_5.x86_64            libgomp-8.5.0-4.el8_5.x86_64
​
Complete!
[root@localhost yum.repos.d]# yum -y install gcc-c++
Last metadata expiration check: 0:06:19 ago on Tue 08 Nov 2022 02:41:44 PM CST.
Dependencies resolved.
================================================================================
 Package               Architecture Version               Repository       Size
================================================================================
Installing:
 gcc-c++               x86_64       8.5.0-4.el8_5         AppStream        12 M
Upgrading:
 libstdc++             x86_64       8.5.0-4.el8_5         base            453 k
Installing dependencies:
 libstdc++-devel       x86_64       8.5.0-4.el8_5         AppStream       2.0 M
​
Transaction Summary
================================================================================
Install  2 Packages
Upgrade  1 Package
​
Total download size: 15 M
Downloading Packages:
(1/3): libstdc++-8.5.0-4.el8_5.x86_64.rpm       168 kB/s | 453 kB     00:02
(2/3): libstdc++-devel-8.5.0-4.el8_5.x86_64.rpm 217 kB/s | 2.0 MB     00:09
(3/3): gcc-c++-8.5.0-4.el8_5.x86_64.rpm         219 kB/s |  12 MB     00:57
--------------------------------------------------------------------------------
Total                                           263 kB/s |  15 MB     00:57
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Upgrading        : libstdc++-8.5.0-4.el8_5.x86_64                         1/4
  Running scriptlet: libstdc++-8.5.0-4.el8_5.x86_64                         1/4
  Installing       : libstdc++-devel-8.5.0-4.el8_5.x86_64                   2/4
  Installing       : gcc-c++-8.5.0-4.el8_5.x86_64                           3/4
  Cleanup          : libstdc++-8.5.0-3.el8.x86_64                           4/4
  Running scriptlet: libstdc++-8.5.0-3.el8.x86_64                           4/4
  Verifying        : gcc-c++-8.5.0-4.el8_5.x86_64                           1/4
  Verifying        : libstdc++-devel-8.5.0-4.el8_5.x86_64                   2/4
  Verifying        : libstdc++-8.5.0-4.el8_5.x86_64                         3/4
  Verifying        : libstdc++-8.5.0-3.el8.x86_64                           4/4
​
Upgraded:
  libstdc++-8.5.0-4.el8_5.x86_64
Installed:
  gcc-c++-8.5.0-4.el8_5.x86_64       libstdc++-devel-8.5.0-4.el8_5.x86_64
​
Complete!
 

2、安装docker依赖

yum install -y yum-utils

[root@localhost yum.repos.d]#  yum install -y yum-utils
Last metadata expiration check: 0:00:52 ago on Tue 08 Nov 2022 02:41:44 PM CST.
Dependencies resolved.
================================================================================
 Package            Architecture    Version                 Repository     Size
================================================================================
Installing:
 yum-utils          noarch          4.0.21-3.el8            base           73 k
​
Transaction Summary
================================================================================
Install  1 Package
​
Total download size: 73 k
Installed size: 22 k
Downloading Packages:
yum-utils-4.0.21-3.el8.noarch.rpm               151 kB/s |  73 kB     00:00
--------------------------------------------------------------------------------
Total                                           151 kB/s |  73 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : yum-utils-4.0.21-3.el8.noarch                          1/1
  Running scriptlet: yum-utils-4.0.21-3.el8.noarch                          1/1
  Verifying        : yum-utils-4.0.21-3.el8.noarch                          1/1
​
Installed:
  yum-utils-4.0.21-3.el8.noarch
​
Complete!
​

3、设置镜像仓库

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@localhost yum.repos.d]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4、安装docker

sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

 出现报错

 在原命令后面添加红框中任意一个 即可

 

[root@localhost yum.repos.d]# sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Docker CE Stable - x86_64                                                                                                                                 37 kB/s |  31 kB     00:00
Dependencies resolved.
=========================================================================================================================================================================================
 Package                                         Architecture                 Version                                                       Repository                              Size
=========================================================================================================================================================================================
Installing:
 containerd.io                                   x86_64                       1.6.9-3.1.el8                                                 docker-ce-stable                        33 M
 docker-ce                                       x86_64                       3:20.10.21-3.el8                                              docker-ce-stable                        21 M
 docker-ce-cli                                   x86_64                       1:20.10.21-3.el8                                              docker-ce-stable                        30 M
 docker-compose-plugin                           x86_64                       2.12.2-3.el8                                                  docker-ce-stable                        10 M
Installing dependencies:
 container-selinux                               noarch                       2:2.167.0-1.module_el8.5.0+911+f19012f9                       AppStream                               54 k
 docker-ce-rootless-extras                       x86_64                       20.10.21-3.el8                                                docker-ce-stable                       4.6 M
 fuse-overlayfs                                  x86_64                       1.7.1-1.module_el8.5.0+890+6b136101                           AppStream                               73 k
 fuse3                                           x86_64                       3.2.1-12.el8                                                  base                                    50 k
 fuse3-libs                                      x86_64                       3.2.1-12.el8                                                  base                                    94 k
 libslirp                                        x86_64                       4.4.0-1.module_el8.5.0+890+6b136101                           AppStream                               70 k
 slirp4netns                                     x86_64                       1.1.8-1.module_el8.5.0+890+6b136101                           AppStream                               51 k
Installing weak dependencies:
 docker-scan-plugin                              x86_64                       0.21.0-3.el8                                                  docker-ce-stable                       3.8 M
Enabling module streams:
 container-tools                                                              rhel8
​
Transaction Summary
=========================================================================================================================================================================================
Install  12 Packages
​
Total download size: 103 M
Installed size: 394 M
Is this ok [y/N]: y
Downloading Packages:
(1/12): fuse3-3.2.1-12.el8.x86_64.rpm                                                                                                                     85 kB/s |  50 kB     00:00
(2/12): container-selinux-2.167.0-1.module_el8.5.0+911+f19012f9.noarch.rpm                                                                                88 kB/s |  54 kB     00:00
(3/12): fuse3-libs-3.2.1-12.el8.x86_64.rpm                                                                                                               113 kB/s |  94 kB     00:00
(4/12): fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64.rpm                                                                                    162 kB/s |  73 kB     00:00
(5/12): libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64.rpm                                                                                          131 kB/s |  70 kB     00:00
(6/12): slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64.rpm                                                                                       124 kB/s |  51 kB     00:00
(7/12): docker-ce-20.10.21-3.el8.x86_64.rpm                                                                                                              167 kB/s |  21 MB     02:09
(8/12): docker-ce-rootless-extras-20.10.21-3.el8.x86_64.rpm                                                                                              156 kB/s | 4.6 MB     00:30
(9/12): docker-ce-cli-20.10.21-3.el8.x86_64.rpm                                                                                                          160 kB/s |  30 MB     03:08
(10/12): docker-scan-plugin-0.21.0-3.el8.x86_64.rpm                                                                                                      164 kB/s | 3.8 MB     00:23
(11/12): containerd.io-1.6.9-3.1.el8.x86_64.rpm                                                                                                          158 kB/s |  33 MB     03:33
(12/12): docker-compose-plugin-2.12.2-3.el8.x86_64.rpm                                                                                                   162 kB/s |  10 MB     01:04
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                    466 kB/s | 103 MB     03:45
Docker CE Stable - x86_64                                                                                                                                5.8 kB/s | 1.6 kB     00:00
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                 1/1
  Installing       : docker-scan-plugin-0.21.0-3.el8.x86_64                                                                                                                         1/12
  Running scriptlet: docker-scan-plugin-0.21.0-3.el8.x86_64                                                                                                                         1/12
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                                                               2/12
  Installing       : container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                                                               2/12
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                                                               2/12
  Installing       : containerd.io-1.6.9-3.1.el8.x86_64                                                                                                                             3/12
  Running scriptlet: containerd.io-1.6.9-3.1.el8.x86_64                                                                                                                             3/12
  Installing       : docker-ce-cli-1:20.10.21-3.el8.x86_64                                                                                                                          4/12
  Running scriptlet: docker-ce-cli-1:20.10.21-3.el8.x86_64                                                                                                                          4/12
  Installing       : libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                                                                                                            5/12
  Installing       : slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                                                                                                         6/12
  Installing       : fuse3-libs-3.2.1-12.el8.x86_64                                                                                                                                 7/12
  Running scriptlet: fuse3-libs-3.2.1-12.el8.x86_64                                                                                                                                 7/12
  Installing       : fuse3-3.2.1-12.el8.x86_64                                                                                                                                      8/12
  Installing       : fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                                                                      9/12
  Running scriptlet: fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                                                                      9/12
  Installing       : docker-ce-3:20.10.21-3.el8.x86_64                                                                                                                             10/12
  Running scriptlet: docker-ce-3:20.10.21-3.el8.x86_64                                                                                                                             10/12
  Installing       : docker-ce-rootless-extras-20.10.21-3.el8.x86_64                                                                                                               11/12
  Running scriptlet: docker-ce-rootless-extras-20.10.21-3.el8.x86_64                                                                                                               11/12
  Installing       : docker-compose-plugin-2.12.2-3.el8.x86_64                                                                                                                     12/12
  Running scriptlet: docker-compose-plugin-2.12.2-3.el8.x86_64                                                                                                                     12/12
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                                                              12/12
  Running scriptlet: docker-compose-plugin-2.12.2-3.el8.x86_64                                                                                                                     12/12
  Verifying        : fuse3-3.2.1-12.el8.x86_64                                                                                                                                      1/12
  Verifying        : fuse3-libs-3.2.1-12.el8.x86_64                                                                                                                                 2/12
  Verifying        : container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                                                               3/12
  Verifying        : fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                                                                      4/12
  Verifying        : libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                                                                                                            5/12
  Verifying        : slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                                                                                                         6/12
  Verifying        : containerd.io-1.6.9-3.1.el8.x86_64                                                                                                                             7/12
  Verifying        : docker-ce-3:20.10.21-3.el8.x86_64                                                                                                                              8/12
  Verifying        : docker-ce-cli-1:20.10.21-3.el8.x86_64                                                                                                                          9/12
  Verifying        : docker-ce-rootless-extras-20.10.21-3.el8.x86_64                                                                                                               10/12
  Verifying        : docker-compose-plugin-2.12.2-3.el8.x86_64                                                                                                                     11/12
  Verifying        : docker-scan-plugin-0.21.0-3.el8.x86_64                                                                                                                        12/12
​
Installed:
  container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch   containerd.io-1.6.9-3.1.el8.x86_64                          docker-ce-3:20.10.21-3.el8.x86_64
  docker-ce-cli-1:20.10.21-3.el8.x86_64                              docker-ce-rootless-extras-20.10.21-3.el8.x86_64             docker-compose-plugin-2.12.2-3.el8.x86_64
  docker-scan-plugin-0.21.0-3.el8.x86_64                             fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64   fuse3-3.2.1-12.el8.x86_64
  fuse3-libs-3.2.1-12.el8.x86_64                                     libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64         slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64
​
Complete!

CentOS 8 中安装 Docker 出现和 Podman 冲突的问题

root@monitor ~]# yum install docker-ce docker-ce-cli containerd.io
CentOS Linux 8 - AppStream                      669 kB/s | 6.2 MB     00:09    
CentOS Linux 8 - BaseOS                         351 kB/s | 2.3 MB     00:06    
Docker CE Stable - x86_64                       1.1 kB/s | 7.1 kB     00:06    
Docker CE Nightly - x86_64                      327  B/s | 2.6 kB     00:08    
Error:
 Problem 1: problem with installed package podman-2.0.5-5.module_el8.3.0+512+b3b58dca.x86_64
  - package podman-2.0.5-5.module_el8.3.0+512+b3b58dca.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed
  - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64
  - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64
  - cannot install the best candidate for the job
  - package runc-1.0.0-64.rc10.module_el8.3.0+479+69e2ae26.x86_64 is filtered out by modular filtering
 Problem 2: problem with installed package buildah-1.15.1-2.module_el8.3.0+475+c50ce30b.x86_64
  - package buildah-1.15.1-2.module_el8.3.0+475+c50ce30b.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
  - package docker-ce-3:20.10.1-3.el8.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed
  - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64
  - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64
  - package containerd.io-1.4.1-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64
  - package containerd.io-1.4.1-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64
  - package containerd.io-1.4.3-3.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64
  - package containerd.io-1.4.3-3.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64
  - cannot install the best candidate for the job
  - package runc-1.0.0-56.rc5.dev.git2abd837.module_el8.3.0+569+1bada2e4.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-64.rc10.module_el8.3.0+479+69e2ae26.x86_64 is filtered out by modular filtering
解决方法:

yum erase podman buildah

在这里插入图片描述

在这里插入图片描述

5、启动docker

[root@localhost yum.repos.d]# sudo systemctl start docker

6、测试

[root@localhost yum.repos.d]#  sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:e18f0a777aefabe047a671ab3ec3eed05414477c951ab1a6f352a06974245fe7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值