CentOS6.5下安装Docker - Go语言中文社区

CentOS6.5下安装Docker


一、简介

        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 环境搭建

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/lwcaiCSDN/article/details/86493789
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-04-18 19:47:24
  • 阅读 ( 1525 )
  • 分类:Linux

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢