设为首页 收藏本站
查看: 809|回复: 0

[经验分享] building a centos docker base image

[复制链接]

尚未签到

发表于 2015-10-13 07:19:07 | 显示全部楼层 |阅读模式
  http://failshell.io/docker/building-a-centos-docker-base-image/
  


  
  There’s been a lot of buzz lately around the Go programming language. A lot of cool tools have been written using it. One in particular, which has a lot of buzz too: Docker.
Like many others, I’m really interested in Docker, because it has the potential to help me resolve a recurring issue: facilitating software deployments as much as possible.
  Most deployments issues have been solved, for me at least, by using a CM tool like Chef. Problem is, sometimes, you need to roll back a deployment, and even if you use a CM, that’s
gonna be tricky.
  With Docker, you simply have to replace a contrainer, and you are good to go.
  So as I explore that new technology, I plan on posting my findings and experience with it here.
  In this first installment, I will explore building a RHEL/Centos Docker base image.

What is Docker?

  Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack
clusters, public clouds and more.


Requirements


  • a RHEL/CentOS VM
  • a kernel supporting AUFS
  • Docker
  • febootstrap (available in the EPEL repository)
  • IP Forwarding enabled (otherwise, networking in containers won’t work)

Getting our environment ready
  I’ve written a Chef cookbook (use >= 0.1.6) that takes care of setting up a Docker-ready server. I recommend using that to get up and running quickly. Otherwise, make
sure you meet the above requirements before moving on.

Building the image
  We’ll be using febootstrap to create a RHEL/CentOS image in a fakeroot. It mimics the behavior of debootstrap. Very useful to create images for LXC/OpenVZ.


[iyunv@banshee ~]# febootstrap -i iputils -i vim-minimal -i iproute -i bash -i coreutils -i yum centos centos http://centos.mirror.iweb.ca/6.4/os/x86_64/ -u http://centos.mirror.iweb.ca/6.4/updates/x86_64/
febootstrap                                                                                                | 3.7 kB     00:00
febootstrap/primary_db                                                                                     | 4.4 MB     00:03
febootstrap-updates                                                                                        | 3.4 kB     00:00
febootstrap-updates/primary_db                                                                             | 4.4 MB     00:02
Setting up Install Process
Resolving Dependencies
[snip]

  NOTE: Make sure you run febootstrap as
root. Otherwise, you gonna walk into a world of pain with permissions in your container.
  Now that we have our image in our fakeroot, we need to import it into Docker.


[iyunv@banshee ~]# cd centos/
[iyunv@banshee centos]# tar -c . | docker import - centos
5df8a8c8477a

  Our newly created image is now available and ready for use.


[iyunv@banshee centos]# docker images
REPOSITORY          TAG                 ID                  CREATED             SIZE
centos              latest              5df8a8c8477a        38 seconds ago      316.8 MB (virtual 316.8 MB)


Testing our new image
  Let’s see if it works.


[iyunv@banshee centos]# docker run centos /bin/ping google.com -c 1
PING google.com (24.200.237.123) 56(84) bytes of data.
64 bytes from 24.200.237.123: icmp_seq=1 ttl=60 time=10.7 ms
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 13ms
rtt min/avg/max/mdev = 10.742/10.742/10.742/0.000 ms



[iyunv@banshee centos]# docker run -t -i centos /bin/bash
bash-4.1# uname -r
3.10.5-3.el6.x86_64
bash-4.1# hostname
d393248f8119

  That’s it.
  In the next installment, I will explain how to customize our new base image to run a website using Nginx.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-126000-1-1.html 上篇帖子: Docker: 利用Linux容器实现可移植的应用部署 下篇帖子: Docker入门
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表