关于docker:docker-镜像构建-适用于arm-mips64-sw64-不使用dockerfile

这是我在思否上的第一篇文章,搬运一下本人在春节时因病毒宅在家里时写的文章。

docker这个不便的工具能够疾速的部署本人的利用,然而其中最根本的形式就是创立一个docker image,然而docker hub上并没有咱们所须要的image,因而在某些状况下,能够本人创立一个minimal docker images;介绍一个基于REDHAT系列的制基于该平台的docker images,实用于其余cpu哦,比方mips,sw等

其实咱们能够晓得,docker images的本质是一个mini的rootfs,而咱们通过下述办法制作进去的rootfs,仅仅是一个能用的images,不适用于咱们生产或者开发啦!然而咱们能够在这个根底上进行定制化开发,装咱们须要的软件安装包


# Create a folder for our new root structure
# 创立根文件系统目录
$ export centos_root='/centos_image/rootfs'
$ mkdir -p ${centos_root}
# download and install the centos-release package, it contains our repository sources
# 下载centos-release,这外面蕴含了一个最小minimal rootfs最小的包
$ yum reinstall --downloadonly --downloaddir . centos-release
$ rpm --root ${centos_root} -ivh --nodeps centos-release*.rpm
# 安装包
$ yum -y --installroot=${centos_root} --setopt=tsflags='nodocs' --setopt=override_install_langs=en_US.utf8 install yum
# 将宿主机上的配置cp 到本人创立的根文件目录
$ cp /etc/resolv.conf ${centos_root}/etc
# mount the device tree, as its required by some programms
# 创立根文件目录外面所须要的零碎安装包,不过不同平台的image 存在不同的差别,有些最小的安装包,差tar
$ mount -o bind /dev ${centos_root}/dev
$ chroot ${centos_root} /bin/bash <<EOF
yum install -y procps-ng iputils
yum clean all
EOF
$ rm -f ${centos_root}/etc/resolv.conf
$ umount ${centos_root}/dev
# over
# 创立结束
# 导入docker中,因为是rootfs文件系统,所以须要应用import 参数
$ tar -C ${centos_root} -c . |docker import - centos

接下来是介绍一种基于debian发行版上制作镜像的方法

$ apt install debootstrap -y
# 依据本人的平台arch 以及源的配置批改上面这条命令;
# x86_64 是amd64,aarch64 是arm64
# jessie 是对应的debian版本,能够通过查看系统配置源得悉该零碎的版本号;
$ debootstrap --arch=amd64 --no-check-gpg  jessie rootfs http://mirrors.ustc.edu.cn/debian

假使呈现如下谬误:

E: No such script: /usr/share/debootstrap/scripts/eagle 则须要进入 debootstrap的脚本目录建设相干软链接即可;

$ cd /usr/share/debootstrap/scripts/
$ ln -sf sid eagle

原本想以uos为例子,然而思考uos的仓库源目前仅供外部应用.

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理