码迷,mamicode.com
首页 > 其他好文 > 详细

Docker 安装(官方安装方法)

时间:2020-05-20 18:43:05      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:follow   cti   tps   gen   更新   设置   htm   ranch   依赖   

写在前面

由于Docker-Engine Docker官方已经不推荐使用,无法安装了,所以现在安装Docker-CE。

参考官方文档 https://docs.rancher.cn/rancher2x/install-prepare/basic-environment-configuration.html#_4-1-docker%E5%AE%89%E8%A3%85

安装步骤

1.关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

2.添加yum源

yum install ca-certificates ;
update-ca-trust;
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo-bak #备份

cat << ‘EOF‘ > /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

EOF

3.指定Docker版本

export docker_version=18.09.9;

4.删除旧的docker组件

apt-get remove docker docker-engine docker.io containerd runc -y;

5.更新 apt 源

apt-get update;

6.对系统进行全面的更新升级,推荐升级一下(可选)

apt-get -y upgrade;

7.安装必要的一些系统工具

apt-get -y install apt-transport-https ca-certificates \
curl software-properties-common bash-completion gnupg-agent;

8.安装GPG证书

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | \
sudo apt-key add -;

9.添加Docker APT 源

add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable";

10.更新并安装 Docker-CE

apt-get -y update;
install_version=$( apt-cache madison docker-ce | grep ${docker_version} | awk ‘{print $3}‘ );

11.允许降级安装

apt-get -y install docker-ce=${install_version} docker-ce-cli=${install_version} --allow-downgrades;

12.把当前用户加入docker组

usermod -aG docker $NEW_USER;

13.设置开机启动

systemctl start docker;
systemctl enable docker;

14.清理不需要的依赖

apt-get autoremove -y

锁定Docker版本

安装yum-plugin-versionlock插件

yum install yum-plugin-versionlock

锁定软件包

yum versionlock add docker-ce docker-ce-cli
yum versionlock add docker-ce docker-ce-cli
yum versionlock list

解锁指定的软件包

yum versionlock delete <软件包名称>

解锁所有的软件包

yum versionlock clear

Docker 安装(官方安装方法)

标签:follow   cti   tps   gen   更新   设置   htm   ranch   依赖   

原文地址:https://blog.51cto.com/13760351/2496889

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!