阿里云cenos 6.5 模板上安装 docker
来源:互联网 发布:淘宝店铺布局管理 编辑:程序博客网 时间:2024/05/21 09:28
本章将介绍在阿里云的 Centos6.5 模板上安装 Docker 以及在 Ubuntu 14.04 模板上安装 Docker 的过程
Centos 6.5 模板上使用Docker
首先,通过 ssh 登陆阿里云的服务器,查看系统版本号以及内核版本。
Welcome to aliyun Elastic Compute Service!# lsb_release -aLSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarchDistributor ID: CentOSDescription: CentOS release 6.5 (Final)Release: 6.5Codename: Final# uname -aLinux 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 -yLoaded plugins: securitybase | 3.7 kB 00:00base/primary_db | 4.6 MB 00:00elrepo | 2.9 kB 00:00elrepo/primary_db | 709 kB 00:46elrepo-kernel | 2.9 kB 00:00elrepo-kernel/primary_db | 20 kB 00:01epel | 4.4 kB 00:00epel/primary_db | 6.3 MB 00:01extras | 3.4 kB 00:00extras/primary_db | 29 kB 00:00updates | 3.4 kB 00:00updates/primary_db | 181 kB 00:00Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package kernel-lt.x86_64 0:3.10.59-1.el6.elrepo will be installed--> Finished Dependency ResolutionDependencies Resolved===================================================================================================================================================== Package Arch Version Repository Size=====================================================================================================================================================Installing: kernel-lt x86_64 3.10.59-1.el6.elrepo elrepo-kernel 33 MTransaction Summary=====================================================================================================================================================Install 1 Package(s)Total download size: 33 MInstalled size: 153 MDownloading Packages:kernel-lt-3.10.59-1.el6.elrepo.x86_64.rpm | 33 MB 28:58Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: 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/1Installed: kernel-lt.x86_64 0:3.10.59-1.el6.elrepoComplete!
vi /etc/grub.conf
修改默认的启动内核,新安装的内核一般在第一个,这里把default = 1
改为 default = 0
就好了。
default=1timeout=5splashimage=(hd0,0)/boot/grub/splash.xpm.gzhiddenmenutitle 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.imgtitle 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 -aLinux 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 startStarting cgconfig service: [ OK ]Starting docker: [ OK ]# docker versionClient version: 1.2.0Client API version: 1.14Go version (client): go1.3.3Git commit (client): fa7b24f/1.2.0OS/Arch (client): linux/amd642014/11/05 21:03:08 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
使用 docker -d
来查看详细的启动过程。
# docker -d2014/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 docker0Could 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-checkconfigKernel configuration not found at /proc/config.gz; searching...Kernel configuration found at /boot/config-3.10.59-1.el6.elrepo.x86_64--- Namespaces ---Namespaces: enabledUtsname namespace: enabledIpc namespace: enabledPid namespace: enabledUser namespace: missingNetwork namespace: enabledMultiple /dev/pts instances: enabled--- Control groups ---Cgroup: enabledCgroup clone_children flag: enabledCgroup device: enabledCgroup sched: enabledCgroup cpu account: enabledCgroup memory controller: enabledCgroup cpuset: enabled--- Misc ---Veth pair device: enabledMacvlan: enabledVlan: enabledFile capabilities: enabledNote : Before booting a new kernel, you can check its configurationusage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig
可以看到 Control groups
项目都是支持的,所以我们暂时忽略这个告警。
测试使用
由于 Aliyun 的网络直接 pull 官方镜像也不是很稳定,这里推荐使用Dockerpool
官方网站的标准ubuntu
镜像来测试。
下载镜像,重新标记镜像。
# docker pull dl.dockerpool.com:5000/ubuntu:14.04# docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEdl.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 ubunturoot@66ff9a55a4f5:/# ping www.dockerpool.comPING 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
- 阿里云 ubuntu 14.04 模板上安装 docker
- Docker 在阿里云上安装
- 阿里云上centos6安装docker问题!
- 阿里云linux上安装docker
- 阿里云上ECS中安装docker
- 阿里云 安装docker
- 阿里云 安装 docker
- 在阿里云的CentOS上安装docker
- ECS上安装docker运行阿里云日志服务demo
- cenos 7 上安装phpmyadmin
- [Docker 入门--安装篇]阿里云ECS服务器Centos系统上安装docker
- CenOS 6.5 + Win7 安装
- 阿里云 ECS 安装docker
- cenos 6.5安装VSFTPD服务器
- Linux CenOs 6.5 安装 SSH
- 阿里云Centos6.5安装配置docker
- 阿里云Centos6.6安装配置docker
- C++编程思想第二章例题笔记
- Linux驱动开发十:按键中断之输入子系统
- 提交代码到svn时服务器重启导致svn无法更新问题解决办法
- Git使用图解教程
- 11.5 找window 三种方法
- 阿里云cenos 6.5 模板上安装 docker
- UVA 12108
- 最简单的Phoenix 访问 HBase例子
- spring mvc数据绑定时通过去除html标签防止js注入
- PB50最受欢迎博客评选领奖品通知
- KMP算法
- 1.1 polynomial curve fitting
- spring缓存集成memcache
- 深入浅出 - Android系统移植与平台开发(十) - led HAL简单设计案例分析