问题是假设我想制作我的 linux 容器。第一个命令总是:-
sudo lxc-create -t debian -n p1
Run Code Online (Sandbox Code Playgroud)
模板名称通常是“ubuntu”,但由于我是 Debian 粉丝,因此已将其替换为 debian。两者的最终结果都是一样的,它开始通过写在 /usr/share/lxc/templates 的 lxc-debian 模板从 debian.org 下载组件。
$ sudo lxc-create -t debian -n debian-n
[sudo] password for shirish:
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/debian/rootfs-wheezy-amd64 ...
Downloading debian minimal ...
I: Retrieving Release
Run Code Online (Sandbox Code Playgroud)
我确实有一个本地 debian-wheezy.iso 映像文件。有没有办法告诉它使用本地 .iso 图像而不是访问网络。
jmt*_*mtd 12
提供给的参数-t是/usr/share/lxc/templates. 查看lxc-debian模板,执行下载的例程称为download_debian(),工作由debootstrap:
debootstrap --verbose --variant=minbase --arch=$arch \
--include=$packages \
"$release" "$cache/partial-$release-$arch" $MIRROR
Run Code Online (Sandbox Code Playgroud)
查看联机帮助页,debootstrap可以为镜像文件使用本地目录而不是网络地址
…MIRROR can be an http:// or https:// URL, a file:/// URL,
or an ssh:/// URL.
Run Code Online (Sandbox Code Playgroud)
因此,要使用本地数据,请将 ISO 挂载到文件系统的某个位置;定义 MIRROR 环境变量;调用lxc-create.
签名的发布文件似乎不在我尝试的 ISO 中,所以我还必须传递--no-check-gpg给debootstrap,这意味着编辑模板文件/usr/share/lxc/templates以添加参数:
--- lxc-debian~ 2015-03-04 10:04:12.628619962 +0000
+++ lxc-debian 2015-03-04 10:04:17.420619851 +0000
@@ -232,7 +232,6 @@
# download a mini debian into a cache
echo "Downloading debian minimal ..."
debootstrap --verbose --variant=minbase --arch=$arch \
+ --no-check-gpg \
--include=$packages \
"$release" "$cache/partial-$release-$arch" $MIRROR
if [ $? -ne 0 ]; then
Run Code Online (Sandbox Code Playgroud)
所以,一旦调整:
# mount -o loop debian-7.8.0-amd64-CD-1.iso /mnt
# export MIRROR=file:///mnt
# lxc-create -t debian -n p1 -- -r wheezy
Run Code Online (Sandbox Code Playgroud)
工作。
| 归档时间: |
|
| 查看次数: |
7987 次 |
| 最近记录: |