跳到主要内容

四、CentOS Docker 安装

Docker 可以运行在 CentOS 上,但对 CentOS 系统版本和内核版本有一定的要求

1、 CentOS的版本必须在6.5+,且必须是64位,然后必须是发行版本;
2、 如果是DockerCE,则要求系统版本是7.0+
3、 如果是CentOS7,则要求系统内核版本为3.10以上;

4、 如果是CentOS6.5或更高的版本的CentOS上,则要求系统内核版本为2.6.32-431或者更高版本;

查看 CentOS 系统内核版本

如果你不确定自己的 CentOS 的内核版本是多少,可以使用 uname -r 命令查看一下

[root@pottercoding.cn ~]# uname -r
3、10.0-327.el7.x86_64

CentOS 安装 Docker

目前最快速的安装 Docker 的方式是使用官方给出的脚本 https://get.docker.com/

只需要在终端里输入以下命令即可开始安装

[root@pottercoding.cn ~]# curl -fsSL get.docker.com -o get-docker.sh
[root@pottercoding.cn ~]# sudo sh get-docker.sh
...
...
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker your-user
Remember to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group grants the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.