一、 Docker的安装
https://docs.docker.com/install/linux/docker-ce/centos/
CentOS7 上安装:
1. 卸载旧版本
较旧的Docker版本称为docker
或docker-engine
。如果已安装这些程序,请卸载它们以及相关的依赖项。
$ sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
2. 安装所需包
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
3. 设定稳定版存储库
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4.安装稳定版
yum install docker-ce docker-ce-cli containerd.io
5. 安装指定版本
yum list docker‐ce ‐‐showduplicates | sort ‐r yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
6. 检查是否安装成功
docker run hello-world
1 [root@app-01 ~]# docker run hello-world 2 Unable to find image 'hello-world:latest' locally 3 Trying to pull repository docker.io/library/hello-world ... 4 latest: Pulling from docker.io/library/hello-world 5 78445dd45222: Pull complete 6 Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 7 8 Hello from Docker! 9 This message shows that your installation appears to be working correctly. 10 11 To generate this message, Docker took the following steps: 12 1. The Docker client contacted the Docker daemon. 13 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 14 3. The Docker daemon created a new container from that image which runs the 15 executable that produces the output you are currently reading. 16 4. The Docker daemon streamed that output to the Docker client, which sent it 17 to your terminal. 18 19 To try something more ambitious, you can run an Ubuntu container with: 20 $ docker run -it ubuntu bash 21 22 Share images, automate workflows, and more with a free Docker ID: 23 https://cloud.docker.com/ 24 25 For more examples and ideas, visit: 26 https://docs.docker.com/engine/userguide/
CentOS6x上的安装:
官方文档要求Linux kernel至少3.8以上,且docker只能运行在64位的系统中。CentOS6x的内核版本为2.6,因此必须要先升级内核。
1. 升级内核(带aufs模块)
cd /etc/yum.repos.d
wget http://www.hop5.in/yum/el6/hop5.repo
yum install kernel-ml-aufs kernel-ml-aufs-devel
修改grub的主配置文件/etc/grub.conf,设置default=0,表示第一个title下的内容为默认启动的kernel(一般新安装的内核在第一个位置),将1改为0
重启,再查看内核
[root@wls12c ~]$ uname -r
3.10.5-3.el6.x86_64
查看是否支持aufs
[root@wls12c ~]$ grep aufs /proc/filesystems
nodev aufs
2. 首先关闭selinux:
setenforce 0
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
3. 在Fedora EPEL源中已经提供了docker-io包,下载安装epel:
rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm sed -i 's/^mirrorlist=https/mirrorlist=http/' /etc/yum.repos.d/epel.repo
4、安装docker-io:
yum -y install docker-io
卸载
sudo yum remove docker-ce sudo rm -rf /var/lib/docker
删除旧的内核
当前内核: uname -a
查看所有内核版本: rpm -qa | grep kernel
删除不需要的内核: yum remove kernel-2.6.32-693.el7.x86_64