码迷,mamicode.com
首页 > 其他好文 > 详细

Docker生产实践(六)

时间:2017-01-19 21:41:39      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:clean   int   wget   dir   ade   base   style   实践   image   

镜像构建思路

思路:分层设计

最底层:系统层,构建自己适用的不同操作系统镜像;

中间层:根据运行环境,如php、java、python等,构建业务基础运行环境层镜像;

最上层:根据具体的业务模块,构建应用服务层镜像。

技术分享

目录构建树结构

技术分享

案例1:centos 7系统镜像构建

cd /root
mkdir -p /root/docker/system/centos
cd /root/docker/system/centos
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo  # 下载阿里RHEL 7 epel源
cp /etc/yum.repos.d/epel.repo epel.repo

创建镜像文件

vim Dockerfile
# This Dockerfile
 
# Base image
FROM centos
 
# Who
MAINTAINER shhnwangjian xxx@163.com
 
# EPEL
ADD epel.repo /etc/yum.repos.d/

# Base pkg
RUN yum install -y wget supervisor git tree net-tools sudo psmisc mysql-devel && yum clean all

构建镜像

docker build -t shhnwangjian/centos:base .

技术分享

 

案例2:基于案例1的centos系统镜像,构建python运行环境镜像

mkdir -p /root/docker/runtime/python
cd /root/docker/runtime/python

创建镜像文件

vim Dockerfile
# Base image
FROM shhnwangjian/centos:base

# Who
MAINTAINER shhnwangjian xxx@163.com

# Python env
RUN yum install -y python-devel python-pip supervisor

# Upgrade pip
RUN pip install --upgrade pip

构建镜像

docker build -t shhnwangjian/python .

技术分享

 

Docker生产实践(六)

标签:clean   int   wget   dir   ade   base   style   实践   image   

原文地址:http://www.cnblogs.com/shhnwangjian/p/6308548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!