Centos 安装 Docker
Docker 支持以下的 64 位 CentOS 版本:
- CentOS 6
- CentOS 7
- CentOS 8
- 更高版本...
Centos 6 安装Docker
-
请用Centos 6.9 以上版本
yum -y 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
service docker start
-
看docker 状态
service docker status
Centos 7(包括7的版本) 以上版本,
官方安装说明 :
https://docs.docker.com/engine/install/centos/
官方安装命令:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
使用国内 daocloud 一键安装命令:
curl -sSL https://get.daocloud.io/docker | sh
旧版本卸载(带上官方说明)
Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
设置仓库
安装所需的软件包。yum-utils 提供了 yum-config-manager ,并且 device mapper 存储驱动程序需要 device-mapper-persistent-data 和 lvm2。
官方说明
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
SET UP THE REPOSITORY Install the yum-utils package (which provides the yum-config-manager utility) and set up the stable repository.
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
使用以下命令来设置稳定的仓库。
使用官方源地址(比较慢)
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
国内源地址(下载快啊,肯定选择这个啊):
阿里云
$ sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
清华大学源
$ sudo yum-config-manager \
--add-repo \
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
安装 Docker Engine-Community 安装最新版本的 Docker Engine-Community 和 containerd,或者转到下一步安装特定版本:
$ sudo yum install docker-ce docker-ce-cli containerd.io
如果提示您接受 GPG 密钥,请选是。
Docker版本说明
-
列出存储库中可用的版本:
$ yum list docker-ce --showduplicates | sort -r docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
-
安装指定版本的Docker
$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io 启动 Docker。
-
启动Docker
$ sudo systemctl start docker