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

1次阅读

共计 1606 个字符,预计需要花费 5 分钟才能阅读完成。

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

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 的仓库源目前仅供外部应用.

正文完
 0