centos和ubuntu上安装docker

 
在Centos6.8上安装

一、查看系统版本

二、安装EPEL

因为系统自带的repo中不带docker需要安装epel

1
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

三、安装Docker

1
yum install -y docker-io

可能会安装失败,如果有问题直接源码安装

1
yum install https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm

四、启动Docker

 五、查看Docker版本

 

在Centos7.X上安装

一、查看系统版本

二、卸载旧版本

1
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

三、安装依赖

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

四、设置稳定的仓库

1
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

五、安装 Docker Engine-Community

1
yum install docker-ce docker-ce-cli containerd.io

如果要安装特定版本,使用如下命令查询后安装

1
yum list docker-ce --showduplicates | sort -r
1
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

六、启动Docker

1
systemctl start docker

七、查看Docker版本

1
docker version

在Ubuntu14.04及以上版本安装

一、查看系统版本

目前仅支持以下3个64 bit的Ubuntu 版本,支持x86_64 和armhf (ARM)硬件架构。 

  • Yakkety 16.10
  • Xenial 16.04 (LTS)
  • Trusty 14.04 (LTS)

二、卸载旧版本

1
sudo apt-get remove docker docker-engine docker-ce docker.io

三、更新apt包索引

1
sudo apt-get update

四、安装linux-image-extra-* 以便docker能使用aufs存储驱动

1
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual

五、安装以下包以使apt可以通过HTTPS使用存储库(repository)

1
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common

六、为了确认所下载软件包的合法性,需要添加软件源的 GPG 密钥

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

七、检查GPG Key信息是否正确

1
sudo apt-key fingerprint 0EBFCD88

八、安装存储库

1
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

九、再更新下apt包索引

1
sudo apt-get update

十、安装最新版本的Docker CE

1
sudo apt-get -y install docker-ce

十一、测试是否安装成功

1
sudo docker run hello-world

出现报错(docker的版本和linux的内核版本不兼容),升级linux内核,执行下列命令,并重启

1
sudo apt-get install --install-recommends linux-generic-lts-xenial
1
sudo reboot

十二、查看Docker版本

 
 
原文地址:https://www.cnblogs.com/laogao123/p/11970651.html