# 安装docker
centos安装
- 安装依赖环境
yum -y install gcc
yum -y install gcc-c++
yum install -y yum-utils
卸载旧版本的docker
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-enginexxxxxxxxxx yum remove docker sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine\docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
设置镜像仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker- ce/linux/centos/docker-ce.repo
安装dockerCE
安装前,建议更新一下yums索引
yum makecache fast
yum install docker-ce docker-ce-cli containerd.io
测试docker
docker version
卸载docker
systemctl stop docker yum -y remove docker-ce docker-ce-cli containerd.io rm -rf /var/lib/docker
ubuntu 安装
一键安装的方法 : curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
推荐使用,下边的太啰嗦了
安装依赖环境库
# 更新apt包索引 sudo apt-get update # 安装 apt 依赖包,用于通过HTTPS来获取仓库 sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release
添加docker官方GPG密钥
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
设置仓库
sudo add-apt-repository \ "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \ $(lsb_release -cs) \ stable"
安装docker
sudo apt-get install docker-ce docker-ce-cli containerd.io
卸载
sudo apt-get remove docker docker-engine docker.io containerd runc