CentOS6.5下安装Docker

本文档详细介绍了如何在CentOS 6.5上升级内核至4.4.170以支持Docker,并提供了解决DNS问题和SSL错误的方法。接着,通过安装ELRepo、启用新内核,安装Docker,解决安装过程中可能出现的错误,最后演示了启动Docker和运行hello-world测试。

一、简介

        CentOS 6.5 的内核一般都是2.6,在2.6的内核下,Docker运行会比较卡,所以一般会选择升级到更高版本,本次教程升级版本为4.4.170-1.el6.elrepo.x86_64。

二、升级内核

1、查看内核版本命令

# uname -r

2、导入key(需要root权限):rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

问题1:如果报错 curl: (6) Couldn't resolve host 'www.elrepo.org' 则表示DNS解析有问题,需要配置

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

末尾添加DNS配置,如下图:

 查看nameserver是否显示正确:

重新导入key。

问题2:如果报curl: (35) SSL connect error错误则输入

# yum update nss

DNS配置完成,重新运行:

# 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、修改引导文件,将默认引导改为0

# vi /etc/grub.conf  # 改为default=0

 6、重启查看版本

# reboot

重启完成后查看内核版本:

# uname -r
4.4.170-1.el6.elrepo.x86_64

 三、安装docker

1、安装docker

# yum install docker-io

如果提示错误:No package docker-io available,则运行

# yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

然后再次执行上面的安装命令。

2、启动dacker

# service docker start

3、查看docker版本

# docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): linux/amd64
Server version: 1.7.0
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 0baf609
OS/Arch (server): linux/amd64

问题:这里可能会报一个错误

// 启动以后提示
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

// 或者查看status时提示以下内容
# docker status
docker 已死,但 pid 文件仍存

//查看日志提示如下
# tail -f /var/log/docker
time="2015-03-09T16:05:29+08:00" level="info" msg="+job serveapi(unix:///var/run/docker.sock)"
time="2015-03-09T16:05:29+08:00" level="info" msg="WARNING: You are running linux kernel version 2.6.32-431.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.8.0."
time="2015-03-09T16:05:29+08:00" level="info" msg="Listening for HTTP on unix (/var/run/docker.sock)"
/usr/bin/docker: relocation error: /usr/bin/docker: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference

 那么运行以下内容:

# yum install device-mapper-event-libs
// 然后重启docker
# docker restart

4、运行hello-world

# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

这样docker就算安装成功了。

四、卸载Docker

查看已安装的包:

# yum list installed | grep docker

删除软件包:

# yum -y remove docker-io.x86_64

删除镜像/容器:

# rm -rf /var/lib/docker

参考文档:

Centos 6.5 安装 Docker(爬坑问题解决)

centos6.5安装docker报错

Centos6.5下docker 环境搭建

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值