以下操作均在 Debian 12
上面进行操作,其他系统应该也行,可以自测。
# 注意,请不要在生产环境操作。
sed -i "s@bookworm@trixie@g" /etc/apt/sources.list
apt update
apt upgrade
apt install sudo vim wget curl qemu-system-loongarch64 qemu-user-static debian-ports-archive-keyring debootstrap git git-lfs
systemctl restart systemd-binfmt.service
安装 Docker Engine
官方文档:https://docs.docker.com/engine/install/debian/
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl start docker
龙芯官方新世界仓库:https://lcr.loongnix.cn/search
如果你希望自己构建基础镜像,可以继续看下面的操作,否则直接使用新世界仓库的镜像即可
cd /opt
git clone --depth=1 https://github.com/debuerreotype/debuerreotype
修改 debuerreotype
代码
懒人链接:https://github.com/loong64/docker-debian-artifacts/tree/dist-loong64
cd /opt/debuerreotype
####
# 这样做的原因是因为 snapshot.debian.org 网站的 debian-port 最近一次快照是 2023-07 年的
# 缺失很多依赖,所以替换成最新的 debian-ports 仓库
sed -i 's@echo "http://snapshot.debian.org/archive/$archive/$t"@# echo "http://snapshot.debian.org/archive/$archive/$t"@g' scripts/.snapshot-url.sh
echo 'echo "http://deb.debian.org/debian-ports"' >> scripts/.snapshot-url.sh
git diff
diff --git a/scripts/.snapshot-url.sh b/scripts/.snapshot-url.sh
index d804de9..de1c57c 100755
--- a/scripts/.snapshot-url.sh
+++ b/scripts/.snapshot-url.sh
@@ -20,4 +20,5 @@ timestamp="${1:-}"; shift || eusage 'missing timestamp'
archive="${1:-debian}"
t="$(date --date "$timestamp" '+%Y%m%dT%H%M%SZ')"
-echo "http://snapshot.debian.org/archive/$archive/$t"
+# echo "http://snapshot.debian.org/archive/$archive/$t"
+echo "http://deb.debian.org/debian-ports"
ARCH=loong64 SUITE=unstable CODENAME="" TIMESTAMP="today 00:00:00" ./.validate-debian.sh
# 之后会在 validate 目录生成所需要的文件。
开始制作镜像
cd validate/20231204/loong64/sid
cat > Dockerfile << "EOF"
FROM scratch
ADD rootfs.tar.xz /
CMD ["bash"]
EOF
# slim 也拷贝一份
cp Dockerfile slim/Dockerfile
构建 debian:sid
和 debian:sid-slim
docker build -t debian:sid . --load
cd slim
docker build -t debian:sid-slim . --load
# 最终成果
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
debian sid 37b9a5bcb70f 7 hours ago 167MB
debian sid-slim 0b0915f3d8da 9 hours ago 126MB
容器运行
docker run --rm -it debian:sid-slim bash
name -a
exit
# 特权启动
docker run --rm --privileged -it debian:sid-slim bash
name -a
exit