如何手动安装Docker?

写作原因:当前许多朋友在安装Docker的时候会遇到这样那样的问题,导致安装Docker失败,无法体验丝滑般的docker容器带了的欢快,特此写一篇手动安装docker的教程,涵盖了Ubuntu 、Debian、CentOS、RedHat主流操作系统

Ubuntu/Debian

1、删除之前安装的docker

apt-get remove docker docker-engine docker.io

2、安装依赖

apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common

3、添加信任的依赖(debian)

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

Ubuntu:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4、添加软件仓库(debian)

add-apt-repository \

   "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \

   $(lsb_release -cs) \

   stable"

Ubuntu:

add-apt-repository \

   "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \

   $(lsb_release -cs) \

   stable"

5、安装

apt-get update

apt-get install docker-ce

CentOS/RedHat

1、删除之前安装的docker

yum remove docker docker-common docker-selinux docker-engine

2、安装一些依赖

yum install -y yum-utils device-mapper-persistent-data lvm2 wget

3、配置docker的安装源

wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo

4、将安装源替换成清华源

sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo

5、安装

yum makecache fast

yum install docker-ce

猜你喜欢

转载自blog.csdn.net/u011630259/article/details/124533056