Centos下Docker安装指定版本

来源:互联网 发布:python语言基本语句 编辑:程序博客网 时间:2024/05/26 15:59

参考官网:https://www.docker.com/products/docker#/linux

一般情况下,docker安装可以使用官网推荐的自动安装脚本,

curl -sSL https://get.docker.com/ | sh

这样可以安装最新的docker-engine,如果因为某些特殊原因,比如机器上的selinux版本不符合docker-engine最新版本的依赖要求,可以使用如下方法手动安装执行的docker版本。

以安装docker-engine-1.12.1为例,以下是安装和初步配置过程


# 如果国内无法连接docker的官方源,可以设置代理,此步骤可略过export http_proxy=http://10.16.3.70:3128export https_proxy=https://10.16.3.70:3128# 清理残余的docker版本yum -y remove docker docker-common container-selinuxyum -y remove docker-selinux# 安装工具yum-utils, 方便下一步设置yum源yum install -y yum-utilsyum-config-manager \    --add-repo \    https://docs.docker.com/engine/installation/linux/repo_files/centos/docker.repo# 查看docker-engine的所有版本,找到期望版本的精确名字,如1.12.2-1.el7.centos# yum list docker-engine --showduplicates# 查看某个docker-engine版本的依赖,如1.12.1依赖docker-engine-selinux, 版本>= 1.12.1-1.el7.centos# yum deplist docker-engine-1.12.1-1.el7.centos# 由于docker-engine会默认安装docker-engine-selinux 13,而安装docker-engine-selinux 13需要将本机的selinux升级,所以手动安装docker-engine-selinux 12yum  -y install docker-engine-selinux-1.12.2-1.el7.centos# 安装docker engineyum -y install docker-engine-1.12.1-1.el7.centos#创建soft linksystemctl enable docker# config docker storage and http_proxy#参考 https://docs.docker.com/engine/admin/systemd/set +edeclare unitConfig=/etc/systemd/system/docker.service.d/mkdir $unitConfigcp ./start.conf $unitConfigcp ./http_proxy.conf $unitConfigset -esystemctl daemon-reload# start dockerservice docker start

配置docker使用了linux的单元配置,包括./start.conf和./http_proxy.conf

./http_proxy.conf主要是为了在docker pull时的http代理,内容如下:

[Service]Environment="HTTP_PROXY=http://10.16.3.70:3128/"

./start.conf是配置docker运行时容器的存储地址,以防docker默认的目录空间不够。

[Service]# 这句是为了unset ExecStartExecStart=ExecStart=/usr/bin/dockerd --graph="/mnt/docker"


1 0
原创粉丝点击