使用debootstrap制作debian-jessie系统docker镜像
先看一下Docker官网提示:In general, you’ll want to start with a working machine that is running the distribution you’d like to package as a parent image. 意思是你制作镜像的机器运行的系统版本要与你要制作的镜像的系统版本相同。
1、安装debootstrap
# aptitude update
# aptitude install -y debootstrap
2、查看帮助,debootstrap的使用方法
# debootstrap --help
debootstrap [OPTION]... <suite> <target> [<mirror> [<script>]]
--arch=A:set the architecture to install (use if no dpkg) [ --arch=powerpc ]
--include=A,B,C:adds specified names to the list of base packages
--no-check-gpg:avoid checking Release file signatures
3、建立debian系统到指定目录
# debootstrap --no-check-gpg --arch=amd64 --include=vim,ca-certificates,net-tools,iputils-ping,iputils-tracepath,iproute,bash,aptitude,locales-all,openssh-server,openssh-client jessie debian-jessie http://mirrors.ustc.edu.cn/debian
4、打包系统目录,并导入到docker(这里仅作测试,可以省略这一步)
# tar -C debian-jessie -c . | docker import - debian-jessie:0.0.1
sha256:10aad891ca3f1db689459b8a230146107eeb6e6f7264051b4adafff25303a3f1
5、打包系统目录,放到指定位置
# cd debian-jessie/
# tar cvzf ../jessie.tar.gz ./
# mkdir -pv /docker/imagesbuilder/opera/debian8-0.0.1/
# mv jessie.tar.gz /docker/imagesbuilder/opera/debian8-0.0.1/
6、编写dockerfile
# cd /docker/imagesbuilder/opera/debian8-0.0.1/
# tree
.
├── Dockerfile
├── jessie.tar.gz
└── source
├── authorized_keys
├── autoboot.sh
├── oupeng-alias.sh
├── oupeng-history.sh
├── sources.list
└── sshd_config
# vim Dockerfile
FROM scratch
MAINTAINER KeithTt shengyongp@oupeng.com
ADD jessie.tar.gz /
ADD source/sources.list /etc/apt/
ADD source/sshd_config /etc/ssh/
ADD source/authorized_keys /root/.ssh/
ADD source/oupeng-alias.sh /etc/profile.d/
ADD source/oupeng-history.sh /etc/profile.d/
ADD source/autoboot.sh /root/bin/autoboot.sh
ENTRYPOINT /root/bin/autoboot.sh && /bin/bash
# cat autoboot.sh
#!/bin/bash
. /etc/profile.d/oupeng-alias.sh
. /etc/profile.d/oupeng-history.sh
services=($(grep 'Default-Start' /etc/init.d/* | grep -v '^[ ]*#' | awk -F: '{print $1":"$NF}' |sed -e 's/[\t ]\+//g'))
for((i=0;i<${#services[@]};i++))
do
levels=$(echo ${services[$i]} | awk -F: '{print $2}')
if [[ $(echo $levels |grep -c '3') -eq 0 ]];then
continue
fi
service=$(echo ${services[$i]} | awk -F: '{print $1}')
if [[ -x $service ]];then
echo "$service" >> /$$
fi
done
for p in $(cat /$$)
do
$p start
done
rm -f /$$
7、build镜像
# docker build -t oupeng/debian8:0.0.1 .
# docker images
8、启动镜像,安装项目所需要的基础程序包
# docker run -it oupeng/debian8:0.0.1
# aptitude update
# aptitude install -y lrzsz vim bash-completion nagios-nrpe-server nagios-plugins-basic supervisor nginx libc6-dev
# aptitude clean
9、安装好基础环境后,提交一个新的镜像
# docker commit -a "KeithTt <shengyongp@oupeng.com>" -m "debian-jessie-transcoder" tender_bardeen oupeng/o12_transcoder:0.1.0
# docker images
# docker save -o o12_transcoder.0.1.0.tar oupeng/o12_transcoder:0.1.0
10、将镜像加载到线上环境
# scp o12_transcoder.0.1.0.tar 117.119.33.166:/root/
# ssh 117.119.33.166
# docker load -i o12_transcoder.0.1.0.tar
11、启动容器,分配IP
# docker run -it -v /proc:/wproc -v /docker/vdisk/v01:/data -m 8G -h $(hostname)-v08 --name $(hostname)-v08 --net=none oupeng/o12_transcoder:0.1.0
# /root/bin/mkipinner.sh uy-s-123-v08 192.168.10.179 20 192.168.1.248
# ssh 192.168.10.179
# aptitude install -y locales-all
这样,一个docker虚拟机就运行起来了。
参考:
https://docs.docker.com/develop/develop-images/baseimages/
https://github.com/KingBing/blog-src/blob/master/使用 debootstrap 建立完整的 Debian 系統.org
https://www.jianshu.com/p/47c4a06a84a4
使用debootstrap制作debian-jessie系统docker镜像的更多相关文章
- 制作nginx+php的docker镜像方法
制作nginx+php的docker镜像方法一.准备安装的工具工具:docker-17.06.0-ce.nginx-1.13.2.PHP-5.5.38 .supervisor配置思路:1.安装dock ...
- 制作基于Buildbot的自动化测试系统Docker镜像
Buildbot in Docker 前言 最近使用Buildbot做了一个自动测试的框架,为了部署方便,可以把测试框架做成Docker镜像,方便部署.这里记录下过程,供大家参考. 项目介绍 项目是一 ...
- 制作ubuntu16.04的docker镜像
来自http://www.jianshu.com/p/029a1ed4fd64 背景 因为笔者是在vagrant转移到docker的玩家,所以对系统镜像情有独钟.如果你是windows.mac用户,那 ...
- 基于vue+springboot+docker网站搭建【七】制作后端spring-boot的docker镜像部署
制作spring-boot的docker镜像并部署 一.下载后端项目:https://github.com/macrozheng/mall 二.修改mall-admin项目的配置文件 修改applic ...
- 制作ssh互信的docker镜像
Dockerfile FROM ubuntu:16.04 # package RUN apt-get update; apt-get -y install ssh COPY ssh_config /e ...
- BI系统打包Docker镜像及容器化部署的具体实现
在过去的几年中,"云"作为明星热词站在了各种新潮技术之中,你可能使用过,但说不清它的原理:或者是没用过,但听过它的大名:也可能连它的名字都没听过,但你对这只蓝色鲸鱼一定十分眼熟.作 ...
- Docker容器技术-优化Docker镜像
一.优化Docker镜像 1.降低部署时间 一个大的Docker应用是如何影响在新Docker宿主机上的部署时间. (1)编写Dockerfile创建一个大Docker镜像 [root@bogon ~ ...
- NodeJS 服务 Docker 镜像极致优化指北
这段时间在开发一个腾讯文档全品类通用的 HTML 动态服务,为了方便各品类接入的生成与部署,也顺应上云的趋势,考虑使用 Docker 的方式来固定服务内容,统一进行制品版本的管理.本篇文章就将我在服务 ...
- 技术分享 | 自制GreatSQL Docker镜像
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 近期打算制作一个GreatSQL的docker镜像,方便社区用户使用GreatSQL. 制作docker镜像的环境基于Ce ...
随机推荐
- MongoDB日常运维操作命令小结
总所周知,MongoDB是一个NoSQL非数据库系统,即一个数据库可以包含多个集合(Collection),每个集合对应于关系数据库中的表:而每个集合中可以存储一组由列标识的记录,列是可以自由定义的, ...
- C. Party Lemonade
链接 [http://codeforces.com/group/1EzrFFyOc0/contest/913/problem/C] 分析 看代码,巧妙的贪心 代码 #include<bits/s ...
- 个人作业——final
一 . 对M1M2的一个总结 我特别感谢我们组的PM.以前我觉得女生学计算机这个专业,跟男生比差太远了.总觉得我们女生就是上上课写写作业考考试还行,但是一到开发什么项目啊,实战之类的,总觉得自己的能力 ...
- Spring基础之 反射(Reflection)
1.了解Class package com.inspire.reflection.Class_api; import java.lang.reflect.Constructor; import jav ...
- vue 路由传参 params 与 query两种方式的区别
初学vue的时候,不知道如何在方法中跳转界面并传参,百度过后,了解到两种方式,params 与 query.然后,错误就这么来了: router文件下index.js里面,是这么定义路由的: { p ...
- RocketMQ事务消息实战
我们以一个订单流转流程来举例,例如订单子系统创建订单,需要将订单数据下发到其他子系统(与第三方系统对接)这个场景,我们通常会将两个系统进行解耦,不直接使用服务调用的方式进行交互.其业务实现步骤通常为: ...
- Jquery ajax $getScript()和$getJSON和JSONP
- ubuntu更改分辨率
1. 输入:$cvt 1920 1080 2 输入: $xrandr 3 输入: $sudo xrandr --newmode "1920x1080_60.00" 173.00 1 ...
- python常用命令和基础运算符
基础运算符 http://www.cnblogs.com/alex3714/articles/5465198.html 身份运算符:is is not成员运算符:in not in ##in 判断元素 ...
- js Dom 编程
1. 节点及其类型: 1). 元素节点 2). 属性节点: 元素的属性, 可以直接通过属性的方式来操作. 3). 文本节点: 是元素节点的子节点, 其内容为文本. 2. 在 html 文档的 ...