centos7 安装docker

step 1: 安装必要的一些系统工具

yum -y install gcc
yum -y install gcc-c++
[root@centos ~]# gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror
base                                                                                                                                | 3.6 kB  00:00:00     
extras                                                                                                                              | 2.9 kB  00:00:00     
jenkins                                                                                                                             | 2.9 kB  00:00:00     
updates                                                                                                                             | 2.9 kB  00:00:00     
jenkins/primary_db                                                                                                                  | 135 kB  00:00:05     
Loading mirror speeds from cached hostfile
 * base: mirror.lzu.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 device-mapper-persistent-data.x86_64.0.0.7.0-0.1.rc6.el7 将被 升级
---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-1.el7 将被 更新
---> 软件包 lvm2.x86_64.7.2.02.171-8.el7 将被 升级
---> 软件包 lvm2.x86_64.7.2.02.185-2.el7_7.2 将被 更新
--> 正在处理依赖关系 lvm2-libs = 7:2.02.185-2.el7_7.2,它被软件包 7:lvm2-2.02.185-2.el7_7.2.x86_64 需要
--> 正在处理依赖关系 libdevmapper.so.1.02(DM_1_02_141)(64bit),它被软件包 7:lvm2-2.02.185-2.el7_7.2.x86_64 需要
---> 软件包 yum-utils.noarch.0.1.1.31-52.el7 将被 安装
--> 正在处理依赖关系 python-kitchen,它被软件包 yum-utils-1.1.31-52.el7.noarch 需要
...................................................
...................................................
  验证中      : 7:lvm2-2.02.171-8.el7.x86_64                                                                                                         16/18 
  验证中      : device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64                                                                               17/18 
  验证中      : 7:device-mapper-event-1.02.140-8.el7.x86_64                                                                                          18/18 

已安装:
  yum-utils.noarch 0:1.1.31-52.el7                                                                                                                         

作为依赖被安装:
  libxml2-python.x86_64 0:2.9.1-6.el7_2.3               python-chardet.noarch 0:2.2.1-3.el7               python-kitchen.noarch 0:1.1.1-5.el7              

更新完毕:
  device-mapper-persistent-data.x86_64 0:0.8.5-1.el7                                    lvm2.x86_64 7:2.02.185-2.el7_7.2                                   

作为依赖被升级:
  device-mapper.x86_64 7:1.02.158-2.el7_7.2        device-mapper-event.x86_64 7:1.02.158-2.el7_7.2   device-mapper-event-libs.x86_64 7:1.02.158-2.el7_7.2  
  device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2   lvm2-libs.x86_64 7:2.02.185-2.el7_7.2            

完毕!

Step 2: 添加软件源信息

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

Step 3: 更新yum软件包索引

yum makecache fast
已加载插件:fastestmirror
base                                                                                                                                | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                                    | 3.5 kB  00:00:00     
extras                                                                                                                              | 2.9 kB  00:00:00     
jenkins                                                                                                                             | 2.9 kB  00:00:00     
updates                                                                                                                             | 2.9 kB  00:00:00     
(1/2): docker-ce-stable/x86_64/updateinfo                                                                                           |   55 B  00:00:00     
(2/2): docker-ce-stable/x86_64/primary_db                                                                                           |  37 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.lzu.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
元数据缓存已建立

Step 4: 安装Docker-CE

yum -y install docker-ce
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.lzu.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.19.03.5-3.el7 将被 安装
........................
........................
  验证中      : libsemanage-2.5-8.el7.x86_64                                                                                                         30/32 
  验证中      : libselinux-python-2.5-11.el7.x86_64                                                                                                  31/32 
  验证中      : selinux-policy-targeted-3.13.1-166.el7.noarch                                                                                        32/32 

已安装:
  docker-ce.x86_64 3:19.03.5-3.el7                                                                                                                         

作为依赖被安装:
  audit-libs-python.x86_64 0:2.8.5-4.el7     checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.107-3.el7 containerd.io.x86_64 0:1.2.10-3.2.el7 
  docker-ce-cli.x86_64 1:19.03.5-3.el7       libcgroup.x86_64 0:0.41-21.el7 libseccomp.x86_64 0:2.3.1-3.el7        libsemanage-python.x86_64 0:2.5-14.el7
  policycoreutils-python.x86_64 0:2.5-33.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7     

作为依赖被升级:
  audit.x86_64 0:2.8.5-4.el7                                audit-libs.x86_64 0:2.8.5-4.el7                libselinux.x86_64 0:2.5-14.1.el7                
  libselinux-python.x86_64 0:2.5-14.1.el7                   libselinux-utils.x86_64 0:2.5-14.1.el7         libsemanage.x86_64 0:2.5-14.el7                 
  libsepol.x86_64 0:2.5-10.el7                              policycoreutils.x86_64 0:2.5-33.el7            selinux-policy.noarch 0:3.13.1-252.el7.1        
  selinux-policy-targeted.noarch 0:3.13.1-252.el7.1        

完毕!

Step 5: 开启Docker服务

systemctl start docker
systemctl enable docker
[root@centos ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 三 2019-11-27 01:58:31 CST; 5s ago
     Docs: https://docs.docker.com
 Main PID: 2596 (dockerd)
   Memory: 42.0M
   CGroup: /system.slice/docker.service
           └─2596 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

11月 27 01:58:30 centos dockerd[2596]: time="2019-11-27T01:58:30.509404378+08:00" level=info msg="scheme \"unix\" not registered, fallback to ...dule=grpc
11月 27 01:58:30 centos dockerd[2596]: time="2019-11-27T01:58:30.509422828+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{...dule=grpc
11月 27 01:58:30 centos dockerd[2596]: time="2019-11-27T01:58:30.509437647+08:00" level=info msg="ClientConn switching balancer to \"pick_firs...dule=grpc
11月 27 01:58:30 centos dockerd[2596]: time="2019-11-27T01:58:30.533603599+08:00" level=info msg="Loading containers: start."
11月 27 01:58:30 centos dockerd[2596]: time="2019-11-27T01:58:30.799301550+08:00" level=info msg="Default bridge (docker0) is assigned with an... address"
11月 27 01:58:31 centos dockerd[2596]: time="2019-11-27T01:58:31.071511098+08:00" level=info msg="Loading containers: done."
11月 27 01:58:31 centos dockerd[2596]: time="2019-11-27T01:58:31.080797671+08:00" level=info msg="Docker daemon" commit=633a0ea graphdriver(s)...n=19.03.5
11月 27 01:58:31 centos dockerd[2596]: time="2019-11-27T01:58:31.083936655+08:00" level=info msg="Daemon has completed initialization"
11月 27 01:58:31 centos dockerd[2596]: time="2019-11-27T01:58:31.169181415+08:00" level=info msg="API listen on /var/run/docker.sock"
11月 27 01:58:31 centos systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

Step 6: 校验是否安装成功

docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:25:41 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:24:18 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Step 7: 配置镜像加速器

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://l6gdi47j.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker

注意:

官方软件源默认启用了最新的软件,您可以通过编辑软件源的方式获取各个版本的软件包。例如官方并没有将测试版本的软件源置为可用,您可以通过以下方式开启。同理可以开启各种测试版本等。

vim /etc/yum.repos.d/docker-ee.repo
将[docker-ce-test]下方的enabled=0修改为enabled=1

安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
yum list docker-ce.x86_64 --showduplicates | sort -r

#   Loading mirror speeds from cached hostfile
#   Loaded plugins: branch, fastestmirror, langpacks
#   docker-ce.x86_64            17.03.1.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
#   Available Packages

# Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
yum -y install docker-ce-[VERSION]

更多可参考此链接
docker安装

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# 1、下载rpm源文件 * rpm下载不了的文件可以到[rpm官方](http://rpm.pbone.net/)进行下载 # 2、执行rpm文件 * 1、以下的rpm文件是有依赖,需要安装顺序进行执行. * 2、执行policycoreutils-python-2.5-29.el7.x86_64.rpm发现报 错误:依赖检测失败: policycoreutils = 2.5-22.el7 被 policycoreutils-python-2.5-22.el7.x86_64 需要 去rpm官方网找了一个`policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm`最新的安装包执行安装 * 3、python-kitchen-1.1.1-5.el7.noarch.rpm可以不需要安装 ``` rpm -ivh libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm rpm -ivh audit-libs-python-2.8.4-4.el7.x86_64.rpm rpm -ivh libcgroup-0.41-20.el7.x86_64.rpm rpm -ivh libsemanage-python-2.5-14.el7.x86_64.rpm rpm -ivh checkpolicy-2.5-8.el7.x86_64.rpm rpm -ivh python-IPy-0.75-6.el7.noarch.rpm rpm -ivh setools-libs-3.3.8-4.el7.x86_64.rpm rpm -ivh policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm rpm -ivh container-selinux-2.74-1.el7.noarch.rpm rpm -ivh libseccomp-2.3.1-3.el7.x86_64.rpm rpm -ivh containerd.io-1.2.0-3.el7.x86_64.rpm rpm -ivh docker-ce-cli-18.09.0-3.el7.x86_64.rpm rpm -ivh docker-ce-18.09.0-3.el7.x86_64.rpm ``` # 3、启动docker ``` systemctl daemon-reload && systemctl restart docker ``` # 4、设置开机启动 * Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. ``` systemctl enable docker.service ``` # 5、验证docker ``` docker version ``` # 参考文章 * [CentOS 7.5离线安装Docker 18.09.3软件](https://jingyan.baidu.com/article/fb48e8becf31a16e632e145f.html)

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值