本章将介绍在阿里云的 Centos6.5 模板上安装 Docker 以及在 Ubuntu 14.04 模板上安装 Docker 的过程

Centos 6.5 模板上使用Docker

首先,通过 ssh 登陆阿里云的server,查看系统版本号号以及内核版本号。

Welcome to aliyun Elastic Compute Service!
# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final
# uname -a
Linux xxxxxxx 2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

升级内核

由于 Docker 推荐使用 3.8 以上内核。所以我们选择使用 YUM 方式来升级内核。

导入 KEY ,安装软件源。在 YUM 的 ELRepo 源中,有 mainline(3.13.1)、long-term(3.10.28)这 2 个内核版本号。考虑到 long-term 更稳定,会长期更新。所以选择这个版本号。

# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# yum --enablerepo=elrepo-kernel install kernel-lt -y
Loaded plugins: security
base | 3.7 kB 00:00
base/primary_db | 4.6 MB 00:00
elrepo | 2.9 kB 00:00
elrepo/primary_db | 709 kB 00:46
elrepo-kernel | 2.9 kB 00:00
elrepo-kernel/primary_db | 20 kB 00:01
epel | 4.4 kB 00:00
epel/primary_db | 6.3 MB 00:01
extras | 3.4 kB 00:00
extras/primary_db | 29 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 181 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package kernel-lt.x86_64 0:3.10.59-1.el6.elrepo will be installed
--> Finished Dependency Resolution Dependencies Resolved =====================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================
Installing:
kernel-lt x86_64 3.10.59-1.el6.elrepo elrepo-kernel 33 M Transaction Summary
=====================================================================================================================================================
Install 1 Package(s) Total download size: 33 M
Installed size: 153 M
Downloading Packages:
kernel-lt-3.10.59-1.el6.elrepo.x86_64.rpm | 33 MB 28:58
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : kernel-lt-3.10.59-1.el6.elrepo.x86_64 1/1
Verifying : kernel-lt-3.10.59-1.el6.elrepo.x86_64 1/1 Installed:
kernel-lt.x86_64 0:3.10.59-1.el6.elrepo Complete!

vi /etc/grub.conf 改动默认的启动内核。新安装的内核一般在第一个,这里把default = 1 改为 default = 0 就好了。

default=1
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.59-1.el6.elrepo.x86_64)
root (hd0,0)
kernel /boot/vmlinuz-3.10.59-1.el6.elrepo.x86_64 ro root=UUID=94e4e384-0ace-437f-bc96-057dd64f42ee rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /boot/initramfs-3.10.59-1.el6.elrepo.x86_64.img
title CentOS (2.6.32-431.23.3.el6.x86_64)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-431.23.3.el6.x86_64 ro root=UUID=94e4e384-0ace-437f-bc96-057dd64f42ee rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /boot/initramfs-2.6.32-431.23.3.el6.x86_64.img
~

重新启动云主机,查看内核是否升级成功。

# uname -a
Linux xxxxxxx 3.10.59-1.el6.elrepo.x86_64 #1 SMP Thu Oct 30 23:46:31 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

安装 Docker

安装软件源,安装 Docker 软件。

# yum install http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm
# yum install docker-io

启动 Docker

安装寻常的方法启动 Docker 之后,发现仍然提示有问题。

# service docker start
Starting cgconfig service: [ OK ]
Starting docker: [ OK ]
# docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.3
Git commit (client): fa7b24f/1.2.0
OS/Arch (client): linux/amd64
2014/11/05 21:03:08 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

使用 docker -d 来查看具体的启动过程。

# docker -d
2014/11/05 21:10:56 docker daemon: 1.2.0 fa7b24f/1.2.0; execdriver: native; graphdriver:
[40a2dcc2] +job serveapi(unix:///var/run/docker.sock)
[info] Listening for HTTP on unix (/var/run/docker.sock)
[40a2dcc2] +job init_networkdriver()
[40a2dcc2.init_networkdriver()] creating new bridge for docker0
Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'
[40a2dcc2] -job init_networkdriver() = ERR (1)
2014/11/05 21:10:56 Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'

提示我们没有空余 ip 分配给 docker0 了。

那我们就使用 --bip 參数来手工分配给 ip 地址。

比方:

# docker --bip=192.168.100.1/24 -d &
[2] 2388
[root@iZ23pznlje4Z ~]# 2014/11/05 21:16:55 docker daemon: 1.2.0 fa7b24f/1.2.0; execdriver: native; graphdriver:
[dc6906e7] +job serveapi(unix:///var/run/docker.sock)
[info] Listening for HTTP on unix (/var/run/docker.sock)
[dc6906e7] +job init_networkdriver()
[dc6906e7] -job init_networkdriver() = OK (0)
2014/11/05 21:16:55 WARNING: Your kernel does not support cgroup swap limit.
[info] Loading containers:
[info] : done.
[dc6906e7] +job acceptconnections()
[dc6906e7] -job acceptconnections() = OK (0)

这里提示警告 Your kernel does not support cgroup swap limit.。我们能够使用 lxc-checkconfig 来检查。

# lxc-checkconfig
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-3.10.59-1.el6.elrepo.x86_64
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: missing
Network namespace: enabled
Multiple /dev/pts instances: enabled --- Control groups ---
Cgroup: enabled
Cgroup clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled --- Misc ---
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
File capabilities: enabled Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig

能够看到 Control groups 项目都是支持的,所以我们临时忽略这个告警。

測试使用

由于 Aliyun 的网络直接 pull 官方镜像也不是非常稳定,这里推荐使用Dockerpool 官方站点的标准ubuntu镜像来測试。

下载镜像,又一次标记镜像。

# docker pull dl.dockerpool.com:5000/ubuntu:14.04
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
dl.dockerpool.com:5000/ubuntu latest 5506de2b643b 12 days ago 197.8 MB
# docker tag 550 ubuntu
# docker rmi dl.dockerpool.com:5000/ubuntu
[dc6906e7] +job image_delete(dl.dockerpool.com:5000/ubuntu)
[dc6906e7] +job log(untag, 5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5, )
[dc6906e7] -job log(untag, 5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5, ) = OK (0)
[dc6906e7] -job image_delete(dl.dockerpool.com:5000/ubuntu) = OK (0)
Untagged: dl.dockerpool.com:5000/ubuntu:latest

启动容器,并測试网络。

# docker run -ti ubuntu
root@66ff9a55a4f5:/# ping www.dockerpool.com
PING www.dockerpool.com (xxx.xxx.xxx.xxx) 56(84) bytes of data.
^C64 bytes from 203.195.193.251: icmp_seq=1 ttl=47 time=31.4 ms

阿里云cenos 6.5 模板上安装 docker的更多相关文章

  1. 阿里云 ubuntu 14.04 模板上安装 docker

    ubuntu 14.04 的内核是 3.13 ,所以内核不用升级. 安装过程例如以下: # apt-get update # apt-get install apt-transport-https # ...

  2. 在阿里云主机的Debian操作系统上安装Docker

    因为需要新搭建饭团网站,所以需要在阿里云的主机上跑数据库,java环境. 考虑到可扩展性和模块化,所以准备最近流行的docker技术.Docker -- 从入门到实践 阿里云主机1核1G,资源不多,所 ...

  3. 尝试在阿里云的Linux服务器器上安装拥有图形界面的Pycharm

    在Linux服务器上跑Python项目发现每次从本地上传文件太过麻烦,于是打算在服务器上安装Pycharm直接写Pycharm代码.   去Pycharm的官网下载Linux版本(支持正版于是我下载了 ...

  4. 在阿里云Ubuntu 14.04 Linux服务器上安装docker

    参考 How To Install and Use Docker: Getting Started 这篇最靠谱的文档在阿里云 Ubuntu  14.04 服务器上成功安装 docker . ---- ...

  5. 轻量级服务器部署方案 -(阿里云CenOS+宝塔)

    一台服务器部署多个应用.可部署前端工程.node服务.数据库等. 一.服务器选择合适的服务器,购买即可.服务器商1.阿里云 2.腾讯云 3.百度云 二.服务器管理面板-宝塔宝塔面板是一款服务器管理软件 ...

  6. [转]阿里云CentOS 7.1使用yum安装MySql5.6.24

    阿里云CentOS 7.1使用yum安装MySql5.6.24 作者:vfhky | 时间:2015-06-25 09:43 | 分类:web 在前面两篇文章<2015博客升级记(四):Cent ...

  7. 阿里云如何打破Oracle迁移上云的壁垒

    2018第九届中国数据库技术大会,阿里云数据库产品专家萧少聪带来以阿里云如何打破Oracle迁移上云的壁垒为题的演讲.Oracle是指“数据库管理系统”,面对Oracle迁移上云的壁垒,阿里云如何能够 ...

  8. 阿里云MySQL远程连接不上问题

    解决阿里云MySQL远程连接不上的问题:step1:1.修改user表:MySQL>update user set host = '%' where user = 'root'; 2.授权主机访 ...

  9. 如何在IIS上发布网站 在阿里云服务器windows server2012r iis上部署.net网站

    如何在IIS上发布网站   本片博客记录一下怎么用IIS发布一个网站,以我自己电脑上一个已经开发完成的网站为例: 1.打开项目 这是我电脑上的一个项目,现在我记录一下将这个项目发布到iis上的整个过程 ...

随机推荐

  1. xshell连接Linux(centos6.8)失败的解决方法

    注意:本人使用的是Centos6.8版本. Centos7以上版本linux命令会又不一样的地方. 启动xshell终端进行连接服务器:使用命令:ssh + ip地址或是手动使用可视化操作窗口操作, ...

  2. 数据结构实验7:实现二分查找、二叉排序(查找)树和AVL树

    实验7 学号:      姓名:     专业: 7.1实验目的 (1) 掌握顺序表的查找方法,尤其是二分查找方法. (2) 掌握二叉排序树的建立及查找. 查找是软件设计中的最常用的运算,查找所涉及到 ...

  3. ES6(Iterator 和 for...of 循环)

    Iterator 和 for...of 循环 1.什么是 Iterator 接口 Iterator 接口功能:用一种相同办法的接口让不同的数据结构得到统一的读取命令的方式 2.Iterator的基本用 ...

  4. 大数据学习——linux系统的网卡配置步骤

    ifconfig 查看ip,没有ip时需要配置 配置步骤: 1输入命令setup,选择network configuration,选择runtool,选择device configuration,选择 ...

  5. Ural 1960 Palindromes and Super Abilities

    Palindromes and Super Abilities Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged ...

  6. HaHa's Morning(状压DP)

    描述 HaHa is so happy today, he is going to participate the 7th Hunan University Programming Contest. ...

  7. HDU 4405 飞行棋上的数学期望

    突然发现每次出现有关数学期望的题目都不会做,就只能找些虽然水但自己还是做不出的算数学期望的水题练练手了 题目大意: 从起点0点开始到达点n,通过每次掷色子前进,可扔出1,2,3,4,5,6这6种情况, ...

  8. 洛谷P1077 摆花

    题目描述 小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆.通过调查顾客的喜好,小明列出了顾客最喜欢的n种花,从1到n标号.为了在门口展出更多种花,规定第i种花不能超过ai盆,摆花时 ...

  9. 【枚举】Southwestern Europe Regional Contest H - Sheldon Numbers

    https://vjudge.net/contest/174235#problem/H [题意] 求[x,y]之间有多少个Sheldon Number Sheldon Number是二进制满足以下条件 ...

  10. HDU 6397 组合数学+容斥 母函数

    Character Encoding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Oth ...