Files
endial 22618a3afc
ci/woodpecker/push/woodpecker Pipeline was successful
docs: 更新说明文档
2026-01-20 10:28:04 +08:00

136 lines
3.8 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Debian
[Debian 系统](https://www.debian.org/)的基础 Docker 镜像。基于官方 [Debian LTS Slim 版本](https://hub.docker.com/_/debian) 镜像。
**版本信息:**
- 12bookworm
**镜像信息:**
* 镜像地址:
* 华为云: swr.cn-north-4.myhuaweicloud.com/colovu/debian
* 依赖镜像:docker.io/library/debian:12-slim
registry.colovu.com/docker-proxy/debian:12-slim
> 后续相关命令行默认使用华为云 SWR 镜像服务器做说明。
**与官方镜像差异:**
- 增加 `default、ustc、aliyun` 源配置文件,可在编译时通过 `ARG` 变量`APT_SOURCE`进行选择
- 增加常用 Shell 脚本文件
- 更新已安装的软件包
- 增加`locales`,并设置默认编码格式为`en_US.utf8`
- 设置默认时区信息为 `Asia/Shanghai`
- 增加`gosu`软件,用作镜像的 non-root 应用执行
- 增加`dumb-init`软件,用作镜像的入口命令,以确保中断被正确响应和转发
- 增加`curl`软件,用作镜像健康检查
## TL;DR
Docker 快速启动命令:
```shell
# 从 Registry 服务器下载镜像并启动
docker run -it swr.cn-north-4.myhuaweicloud.com/colovu/debian:12 /bin/bash
```
---
## 使用说明
**下载镜像:**
```shell
docker pull swr.cn-north-4.myhuaweicloud.com/colovu/debian:12
```
- 12:为镜像的 TAG,可针对性选择不同的 TAG 进行下载;可使用`latest`选择最新的镜像
- 不指定 TAG 时,默认下载`latest`镜像
**查看镜像:**
```shell
docker images
```
**命令行方式运行容器:**
```shell
docker run -it --rm swr.cn-north-4.myhuaweicloud.com/colovu/debian:12 /bin/bash
```
- `-it`:使用交互式终端启动容器
- `--rm`:退出时删除容器
- `swr.cn-north-4.myhuaweicloud.com/colovu/debian:12`:镜像名称及版本标签
- `/bin/bash`:在容器中执行`/bin/bash`命令;如果不执行命令,容器会在启动后立即结束并退出。
以该方式启动后,直接进入容器的命令行操作界面。如果需要退出,直接使用命令`exit`退出。
**后台方式运行容器:**
```shell
docker run -d --name debian swr.cn-north-4.myhuaweicloud.com/colovu/debian:12 tail /dev/stderr
```
- `--name debian`:命名容器为`debian`,可按照实际情况自定义容器名称
- `-d`:以后台进程方式启动容器
- `swr.cn-north-4.myhuaweicloud.com/colovu/debian:12`:镜像名称及版本标签
- `tail /dev/stderr`:在容器中执行`tail /dev/stderr`命令,以防止容器直接退出
以该方式启动后,如果想进入容器,可以使用以下命令:
```shell
docker exec -it debian /bin/bash
```
- `-it`:使用交互式执行
- `debian`:之前启动的容器名
- `/bin/bash`:执行的命令
## 配置修改
### 修改时区信息
可在生成镜像时或容器初始化 Shell 脚本中,使用以下命令:
```shell
# 修改时区为 UTC
ln -fs /usr/share/zoneinfo/UTC /etc/localtime
# 重新配置系统
dpkg-reconfigure -f noninteractive tzdata
```
更新成功后会显示当前时区信息,如:
```shell
Current default time zone: 'Etc/UTC'
Local time is now: Tue Jul 21 09:16:14 UTC 2020.
Universal Time is now: Tue Jul 21 09:16:14 UTC 2020.
```
### 修改字符编码格式
可在生成镜像时或容器初始化 Shell 脚本中,使用以下命令:
``` shell
# 更改默认字符编码为 zh_CN.UTF-8
sed -i -e 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
update-locale LC_ALL=zh_CN.UTF-8 LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8 LC_MESSAGES=POSIX
dpkg-reconfigure -f noninteractive locales
# 设置环境变量
export LC_ALL=zh_CN.UTF-8 LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8
```
更新成功后,可使用`locale`命令查看字符编码信息。
## 更新记录
- 12、bookworm
----
本文原始来源 [Endial Fang](https://gitee.com/colovu) @ [Gitee.com](https://gitee.com)