镜像下载、域名解析、时间同步请点击 阿里巴巴开源镜像站

在新主机上首次安装Docker Engine之前,需要设置Docker存储库。之后,您可以从存储库安装和更新Docker。

设置存储库
安装yum-utils软件包(提供yum-config-manager 实用程序)并设置稳定的存储库。
[root@localhost ~]# yum install -y yum-utils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.lzu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 yum-utils.noarch.0.1.1.31-24.el7 将被 升级
---> 软件包 yum-utils.noarch.0.1.1.31-52.el7 将被 更新
--> 正在处理依赖关系 yum >= 3.4.3-143,它被软件包 yum-utils-1.1.31-52.el7.noarch 需要
--> 正在检查事务
---> 软件包 yum.noarch.0.3.4.3-118.el7.centos 将被 升级
---> 软件包 yum.noarch.0.3.4.3-163.el7.centos 将被 更新
--> 正在处理依赖关系 rpm >= 4.11.3-22,它被软件包 yum-3.4.3-163.el7.centos.noarch 需要
--> 正在处理依赖关系 python-urlgrabber >= 3.10-8,它被软件包 yum-3.4.3-163.el7.centos.noarch 需要
--> 正在检查事务
---> 软件包 python-urlgrabber.noarch.0.3.10-4.el7 将被 升级
---> 软件包 python-urlgrabber.noarch.0.3.10-9.el7 将被 更新
---> 软件包 rpm.x86_64.0.4.11.1-16.el7 将被 升级
--> 正在处理依赖关系 rpm = 4.11.1-16.el7,它被软件包 rpm-python-4.11.1-16.el7.x86_64 需要
--> 正在处理依赖关系 rpm = 4.11.1-16.el7,它被软件包 rpm-libs-4.11.1-16.el7.x86_64 需要
---> 软件包 rpm.x86_64.0.4.11.3-40.el7 将被 更新
--> 正在检查事务
---> 软件包 rpm-libs.x86_64.0.4.11.1-16.el7 将被 升级
--> 正在处理依赖关系 rpm-libs(x86-64) = 4.11.1-16.el7,它被软件包 rpm-build-libs-4.11.1-16.el7.x86_64 需要
---> 软件包 rpm-libs.x86_64.0.4.11.3-40.el7 将被 更新
---> 软件包 rpm-python.x86_64.0.4.11.1-16.el7 将被 升级
---> 软件包 rpm-python.x86_64.0.4.11.3-40.el7 将被 更新
--> 正在检查事务
---> 软件包 rpm-build-libs.x86_64.0.4.11.1-16.el7 将被 升级
---> 软件包 rpm-build-libs.x86_64.0.4.11.3-40.el7 将被 更新
--> 解决依赖关系完成 依赖关系解决 ============================================================================================================================================================================================================================
Package 架构 版本 源 大小
============================================================================================================================================================================================================================
正在更新:
yum-utils noarch 1.1.31-52.el7 base 121 k
为依赖而更新:
python-urlgrabber noarch 3.10-9.el7 base 108 k
rpm x86_64 4.11.3-40.el7 base 1.2 M
rpm-build-libs x86_64 4.11.3-40.el7 base 107 k
rpm-libs x86_64 4.11.3-40.el7 base 278 k
rpm-python x86_64 4.11.3-40.el7 base 83 k
yum noarch 3.4.3-163.el7.centos base 1.2 M 事务概要
============================================================================================================================================================================================================================
升级 1 软件包 (+6 依赖软件包) 总计:3.1 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新 : rpm-libs-4.11.3-40.el7.x86_64 1/14
正在更新 : rpm-4.11.3-40.el7.x86_64 2/14
正在更新 : rpm-build-libs-4.11.3-40.el7.x86_64 3/14
正在更新 : rpm-python-4.11.3-40.el7.x86_64 4/14
正在更新 : python-urlgrabber-3.10-9.el7.noarch 5/14
正在更新 : yum-3.4.3-163.el7.centos.noarch 6/14
正在更新 : yum-utils-1.1.31-52.el7.noarch 7/14
清理 : yum-utils-1.1.31-24.el7.noarch 8/14
清理 : yum-3.4.3-118.el7.centos.noarch 9/14
清理 : rpm-python-4.11.1-16.el7.x86_64 10/14
清理 : python-urlgrabber-3.10-4.el7.noarch 11/14
清理 : rpm-build-libs-4.11.1-16.el7.x86_64 12/14
清理 : rpm-libs-4.11.1-16.el7.x86_64 13/14
清理 : rpm-4.11.1-16.el7.x86_64 14/14
验证中 : python-urlgrabber-3.10-9.el7.noarch 1/14
验证中 : rpm-python-4.11.3-40.el7.x86_64 2/14
验证中 : yum-utils-1.1.31-52.el7.noarch 3/14
验证中 : rpm-4.11.3-40.el7.x86_64 4/14
验证中 : yum-3.4.3-163.el7.centos.noarch 5/14
验证中 : rpm-libs-4.11.3-40.el7.x86_64 6/14
验证中 : rpm-build-libs-4.11.3-40.el7.x86_64 7/14
验证中 : python-urlgrabber-3.10-4.el7.noarch 8/14
验证中 : rpm-python-4.11.1-16.el7.x86_64 9/14
验证中 : rpm-build-libs-4.11.1-16.el7.x86_64 10/14
验证中 : rpm-libs-4.11.1-16.el7.x86_64 11/14
验证中 : yum-utils-1.1.31-24.el7.noarch 12/14
验证中 : yum-3.4.3-118.el7.centos.noarch 13/14
验证中 : rpm-4.11.1-16.el7.x86_64 14/14 更新完毕:
yum-utils.noarch 0:1.1.31-52.el7 作为依赖被升级:
python-urlgrabber.noarch 0:3.10-9.el7 rpm.x86_64 0:4.11.3-40.el7 rpm-build-libs.x86_64 0:4.11.3-40.el7 rpm-libs.x86_64 0:4.11.3-40.el7 rpm-python.x86_64 0:4.11.3-40.el7 yum.noarch 0:3.4.3-163.el7.centos 完毕!

添加下载地址:

yum-config-manager \     --add-repo \     https://download.docker.com/linux/centos/docker-ce.repo

安装DOCKER引擎

安装最新版本的Docker Engine和容器,或转到下一步以安装特定版本: 过程比较漫长 等等就好

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

如果提示您接受GPG密钥,请验证指纹是否匹配 ​​060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35​​,如果是,则接受它。

不出意外 你会看到 成功两个字 ,

启动Docker。  systemctl start docker

别急 如果启动失败了 说明 版本问题导致的

你可以先卸载 再 继续安装 ,当然是选择性安装 根据版本号安装

要安装特定版本的Docker Engine,请在存储库中列出可用版本,然后选择并安装:

一个。列出并排序您存储库中可用的版本。此示例按版本号(从高到低)对结果进行排序,

[root@localhost lib]#  yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror, langpacks
可安装的软件包
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
* extras: mirrors.aliyun.com
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
返回的列表取决于启用了哪些存储库,并且特定于您的CentOS版本(.el7在本示例中以后缀表示)。

b。通过其完全合格的软件包名称安装特定版本,该软件包名称是软件包名称(docker-ce)加上版本字符串(第二列),从第一个冒号(:)一直到第一个连字符,并用连字符(-)分隔。例如,docker-ce-18.09.1。

yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

首先卸载之前的安装 (当然你也可以选择升级linux内核)

yum remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker 执行完成后继续下面的执行

自定义安装

[root@localhost ~]# yum install docker-ce-17.09.1.ce
BDB2053 Freeing read locks for locker 0x72a: 51685/139945979692864
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.lzu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.0.17.09.1.ce-1.el7.centos 将被 安装
--> 解决依赖关系完成 依赖关系解决 =============================================================================================================================================================================================================================================================================
Package 架构 版本 源 大小
=============================================================================================================================================================================================================================================================================
正在安装:
docker-ce x86_64 17.09.1.ce-1.el7.centos docker-ce-stable 21 M 事务概要
=============================================================================================================================================================================================================================================================================
安装 1 软件包 总下载量:21 M
安装大小:21 M
Is this ok [y/d/N]: y
Downloading packages:
docker-ce-17.09.1.ce-1.el7.cen FAILED 91% [==================================================================================================== ] 1.2 B/s | 19 MB 433:07:05 ETA
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.09.1.ce-1.el7.centos.x86_64.rpm: [Errno 12] Timeout on https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.09.1.ce-1.el7.centos.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在尝试其它镜像。
docker-ce-17.09.1.ce-1.el7.centos.x86_64.rpm | 21 MB 00:00:56
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : docker-ce-17.09.1.ce-1.el7.centos.x86_64 1/1
验证中 : docker-ce-17.09.1.ce-1.el7.centos.x86_64 1/1 已安装:
docker-ce.x86_64 0:17.09.1.ce-1.el7.centos 完毕!
[root@localhost ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since 二 2020-04-07 21:52:23 CST; 41min ago
Docs: https://docs.docker.com
Main PID: 51154 (code=exited, status=1/FAILURE) 4月 07 21:52:21 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
4月 07 21:52:21 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
4月 07 21:52:21 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
4月 07 21:52:21 localhost.localdomain systemd[1]: docker.service failed.
4月 07 21:52:23 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling restart.
4月 07 21:52:23 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine.
4月 07 21:52:23 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service
4月 07 21:52:23 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
4月 07 21:52:23 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
4月 07 21:52:23 localhost.localdomain systemd[1]: docker.service failed.
[root@localhost ~]# systemctl start docker.service
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since 二 2020-04-07 22:33:51 CST; 8s ago
Docs: https://docs.docker.com
Main PID: 53799 (dockerd)
Memory: 14.7M
CGroup: /system.slice/docker.service
├─53799 /usr/bin/dockerd
└─53805 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc 4月 07 22:33:50 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:50.384733771+08:00" level=info msg="devmapper: Successfully created filesystem xfs on device docker-253:1-2180700-base"
4月 07 22:33:50 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:50.460507062+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
4月 07 22:33:50 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:50.460884311+08:00" level=warning msg="mountpoint for pids not found"
4月 07 22:33:50 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:50.461183759+08:00" level=info msg="Loading containers: start."
4月 07 22:33:50 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:50.901283597+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
4月 07 22:33:51 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:51.123313352+08:00" level=info msg="Loading containers: done."
4月 07 22:33:51 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:51.140985188+08:00" level=info msg="Docker daemon" commit=19e2cf6 graphdriver(s)=devicemapper version=17.09.1-ce
4月 07 22:33:51 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:51.141114485+08:00" level=info msg="Daemon has completed initialization"
4月 07 22:33:51 localhost.localdomain dockerd[53799]: time="2020-04-07T22:33:51.164127752+08:00" level=info msg="API listen on /var/run/docker.sock"
4月 07 22:33:51 localhost.localdomain systemd[1]: Started Docker Application Container Engine.

然后运行示例程序 在这之前 需要引入国内的镜像地址 当然你有FQ 可以不要的

通过运行​​hello-world​​ 映像来验证是否正确安装了Docker Engine 。

docker run hello-world

配置

/etc/docker 目录下创建 daemon.json

[root@localhost docker]# ll
总用量 8
-rw-r--r-- 1 root root 65 4月 7 22:50 daemon.json
-rw------- 1 root root 244 4月 7 22:33 key.json

然后里面的内容为

{  "registry-mirrors": ["https://alzgoonw.mirror.aliyuncs.com"]  }

保存后 执行 测试命令

[root@localhost docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
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/ [root@localhost docker]# docker run hello-world 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/ [root@localhost docker]#

本文转自:

https://blog.51cto.com/u_15446828/4775102

centos 在线安装 docker的更多相关文章

  1. Centos 7系统在线安装docker

    在线安装docker 以下操作步骤均在root用户下操作 1. 检查内核是否符合要求 Docker 要求 Centos系统的内核版本高于 3.10 ,建议在Centos 7版本命令如下: uname ...

  2. CentOS 7 安装 Docker

    CentOS 7 安装 Docker 这里介绍 ContOS 7 的安装 docker V1.2+,包括阿里云加速 docker 镜像下载的设置,这对提升使用 docker 体验至关重要.其他系统安装 ...

  3. centos在线安装svn

    centos在线安装svn 用下列命令安装svn服务 yum install subversion 创建svn版本库目录 mkdir -p /var/svn/svnrepos 创建版本库 svnadm ...

  4. 在RedHat/CentOS下安装Docker(不升级内核)

    由于内核版本问题,最初仅Ubuntu可以较好的支持Docker.不过,由于RedHat系列OS(REHL.CentOS)是目前主流的Linux服务器操作系统,所以令RedHat系列OS支持Docker ...

  5. 简单介绍一下在CentOS上安装Docker。

    简单介绍一下在CentOS上安装Docker. 前置条件: 64-bit 系统 kernel 3.10+ 1.检查内核版本,返回的值大于3.10即可. $ uname -r 2.使用 sudo 或 r ...

  6. Centos 下面安装 docker

    试过了虚拟机VM ,今天尝试在虚拟机centos 中安装 docker ,入门是看的阮一峰的http://www.ruanyifeng.com/blog/2018/02/docker-tutorial ...

  7. docker学习之路-centos下安装docker

    前言 我要在云服务器上做一个asp.net core的webapi应用,使用docker来部署应用,中间用到的任何组件包括nginx和sqlserver 2017都是用docker来装载运行,所以,这 ...

  8. Centos 在线安装 nginx

    centos 在线安装 nginx 安装nginx ​ 参考文档: http://nginx.org/en/linux_packages.html 中的RHEL/CentOS章节,按照步骤安装repo ...

  9. Centos下安装Docker,并配置国内docker源

    Centos下安装Docker 替换为国内的yum源(可选): mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.re ...

随机推荐

  1. 1、前端--HTML简介、head内常见标签、body内常见标签(特殊符号、div、span、a、img、列表、表格table、表单form)、标签两大属性

    今日内容 HTML简介 HTML是构造网页的骨架>>>:几乎所有的网站都是由HTML构建而成 HTML:超文本标记语言 # 不是一门编程语言 没有任何的逻辑 只有固定的标记功能 &q ...

  2. Solution -「JOISC 2021」古老的机器

    \(\mathcal{Description}\)   Link.   这是一道通信题.   对于长度为一个 \(n\),仅包含字符 X, Y, Z 的字符串 \(s\),将其中 \(n\) 个字符按 ...

  3. Solution -「洛谷 P6292」区间本质不同子串个数

    \(\mathcal{Description}\)   Link.   给定长度为 \(n\),仅包含小写字符的字符串 \(s\),\(m\) 次询问,每次询问一个子串 \(s[l:r]\) 的本质不 ...

  4. Solution -「AGC 012F」「AT 2366」Prefix Median

    \(\mathcal{Description}\)   Link.   给定序列 \(\{a_{2n-1}\}\),将 \(\{a_{2n-1}\}\) 按任意顺序排列后,令序列 \(b_i\) 为前 ...

  5. linux下gdb如何处理coredump错误

    linux下gdb如何处理coredump错误 在编写C++程序中,我们经常会遇到一种错误,segment fault, 这种coredump错误 会导致程序运行时异常退出或者终止,这种错误没有明显错 ...

  6. AI 神经网络理解

    神经网络理解 原文写于2019-12-05,2021-12-08改为markdown

  7. Linux性能优化之磁盘I/O调优

    I/O指标已介绍,那么如何查看系统的这些指标呢? 一.根据工具查性能 二.根据性能找工具 三.磁盘I/O观察实例 iostat 是最常用的磁盘 I/O 性能观测工具,它提供了每个磁盘的 使用率 . I ...

  8. Hbuilderx换行问题(属性合并一行展示)

    1. 标签折行,非吾所愿(格式化代码快捷键:Ctrl + K)  2. 打开工具-设置 3. 点击左侧插件配置,点击右边下侧jsbeautify 4. 将原本的折行长度由120改为1200(长度可根据 ...

  9. XSS Challenge靶场练习

    实验目的 学习xss的基础知识及利用方式. 实验原理 XSS 跨站脚本攻击(Cross Site Scripting),为不和层叠样式表(Cascading Style Sheets, CSS)的缩写 ...

  10. [Matlab]二维隐函数绘图

    MATLAB提供了一个ezplot函数绘制隐函数图形,有三种调用方式: 对于函数f=f(x),ezplot函数的调用格式为: ezplot(f):在默认区间-2pi<=x<=2pi内绘制f ...