官方文档要求Linux kernel至少3.8以上,且docker只能运行在64位的系统中。由于RHEL6和CentOS6的内核版本为2.6,因此必须要先升级内核。
下面以CentOS6.5(64位)为例,介绍下docker安装步骤和使用方法:
一、升级内核(带aufs模块)
1、yum安装带aufs模块的3.10内核(或到这里下载kernel手动安装:http://down.51cto.com/data/1903250)
cd /etc/yum.repos.d
wget http://www.hop5.in/yum/el6/hop5.repo
yum install kernel-ml-aufs kernel-ml-aufs-devel
2、修改grub的主配置文件/etc/grub.conf,设置default=0,表示第一个title下的内容为默认启动的kernel(一般新安装的内核在第一个位置)。
3、重启系统,这时候你的内核就成功升级了。
[root@localhost ~]# uname -r
3.10.5-3.el6.x86_64
查看内核是否支持aufs:
[root@localhost ~]# grep aufs /proc/filesystems
nodev aufs
二、安装docker
1 Log into your machine as a user with sudo or root privileges.
2 Make sure your existing yum packages are up-to-date.
$ sudo yum update
3 Run the Docker installation script.
$ curl -sSL https://get.docker.com/ | sh
This script adds the `docker.repo` repository and installs Docker.
4 Start the Docker daemon.
$ sudo service docker start
5 Verify docker is installed correctly by running a test image in a container.
$ sudo docker run hello-world
#############################################################
centos7下安装docker
uname -r
3.10.0-229.el7.x86_64
Install with yum
-
Log into your machine as a user with
sudo
orroot
privileges. -
Make sure your existing yum packages are up-to-date.
$ sudo yum update
-
Add the yum repo.
$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF
-
Install the Docker package.
$ sudo yum install docker-engine
-
Start the Docker daemon.
$ sudo service docker start
-
Verify
docker
is installed correctly by running a test image in a container.$ sudo docker run hello-world
Install with the script
-
Log into your machine as a user with
sudo
orroot
privileges. -
Make sure your existing yum packages are up-to-date.
$ sudo yum update
-
Run the Docker installation script.
$ curl -sSL https://get.docker.com/ | sh
This script adds the
docker.repo
repository and installs Docker. -
Start the Docker daemon.
$ sudo service docker start
-
Verify
docker
is installed correctly by running a test image in a container.$ sudo docker run hello-world