Docker centos6.x 版本安装

CentOS 6.x 的内核一般都是2.x 或以下,Docker运行会比较卡,所以一般选择升级到更高版本。

升级内核

1. 查看内核版本 > uname -r
2.  a.导入key(需要root权限)> rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
    b.如果报错 curl: (6) Couldn't resolve host 'www.elrepo.org' 则表示DNS解析有问题,需要配置
    c.> vi /etc/sysconfig/network-scripts/ifcfg-eth0
	d.在文件最好添加
     	DNS1=114.114.114.114
    	DNS2=8.8.8.8
	e.查看nameserver是否显示正确 > cat /etc/resolv.conf |grep names
	f.重新导入key,如果报curl: (35) SSL connect error错误则输入 > yum update nss
	g.理论上DNS配置完成
	h.重新运行 > rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
3. 安装ELRepo到CentOS > rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
4. 安装内核 > yum --enablerepo=elrepo-kernel install kernel-lt –y
5.a. 修改引导文件,将默认引导改为0 > vi /etc/grub.conf
	b.default 改为0
6.重启查看版本

安装Docker

1. 运行yum安装 > yum install docker-io
2. 如果报错先安装yum源,提示:No package docker-io available
3. 指定镜像地址再次安装 > yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

注:安装docker,可是源一般是国外源,用这个命令因为被墙,根本安装不了,可以使用下面镜像地址
Ubuntu/Debian: curl -sSL https://get.docker.com | sh
Linux 64bit binary: https://get.docker.com/builds/Linux/x86_64/docker-1.7.1
Darwin/OSX 64bit client binary: https://get.docker.com/builds/Darwin/x86_64/docker-1.7.1
Darwin/OSX 32bit client binary: https://get.docker.com/builds/Darwin/i386/docker-1.7.1
Linux 64bit tgz: https://get.docker.com/builds/Linux/x86_64/docker-1.7.1.tgz
Windows 64bit client binary: https://get.docker.com/builds/Windows/x86_64/docker-1.7.1.exe
Windows 32bit client binary: https://get.docker.com/builds/Windows/i386/docker-1.7.1.exe
Centos 6/RHEL 6: https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm
Centos 7/RHEL 7: https://get.docker.com/rpm/1.7.1/centos-7/RPMS/x86_64/docker-engine-1.7.1-1.el7.centos.x86_64.rpm
Fedora 20: https://get.docker.com/rpm/1.7.1/fedora-20/RPMS/x86_64/docker-engine-1.7.1-1.fc20.x86_64.rpm
Fedora 21: https://get.docker.com/rpm/1.7.1/fedora-21/RPMS/x86_64/docker-engine-1.7.1-1.fc21.x86_64.rpm
Fedora 22: https://get.docker.com/rpm/1.7.1/fedora-22/RPMS/x86_64/docker-engine-1.7.1-1.fc22.x86_64.rpm

启动Docker

service docker start

查看Docker版本

docker --version

卸载Docker

1. 查看已安装的包:> yum list installed | grep docker
2. 删除软件包:> yum -y remove docker-io.x86_64
3. 删除镜像/容器:> rm -rf /var/lib/docker

来源1:https://www.jianshu.com/p/60394d75f21f
来源2:https://blog.csdn.net/kdchxue/article/details/50902580

你可能感兴趣的:(Docker)