62 Commits
Author SHA1 Message Date
yeasy 12c2acca52 fix(命令): 五处照抄跑不起来,另修四处违反本书自己规则的写法
跑不起来的五处:

- 11.5:604 的 Compose 示例里 `db:` 顶在第 0 列,是**顶级键而不是服务**。
  实测 yaml 解析结果是 `{'services': None, 'db': {...}}`,`docker compose up`
  直接报错。同文件其他服务示例都缩进正确。
- 10.3 的 `docker manifest create` 把 `--amend` 当成每个 manifest 的前缀写了
  两遍。upstream `docker/cli` 里它是 `BoolVarP(&opts.amend, "amend", "a", ...)`,
  不取值;用法是 `create MANIFEST_LIST MANIFEST [MANIFEST...]`。照抄不仅参数
  错位,还会打开"修改已有列表"的语义。改为直接跟位置参数。
- 21.7:288 `apk add postgresql-contrib pg-stat-monitor`。核对 Alpine v3.23 的
  APKINDEX(427828 行,直接解包官方索引):这两个包名都**不存在**,Alpine 只
  提供带主版本号的 `postgresql16-contrib` 等;`apk add` 遇到未知包会中止,
  该 Dockerfile 卡在第二步。改为 postgresql16-contrib 并去掉 pg-stat-monitor,
  同时注明原因。
- 19.3:528 用 `pip install --user` 装到 `/root/.local`,运行阶段却 `USER nobody`。
  Debian 的 `/root` 是 0700,nobody 无法进入,容器起来就找不到依赖。改为装到
  `/opt/pydeps`(PYTHONUSERBASE)并同步 COPY 与 PATH。
- 11.8:202 的 `WORDPRESS_REDIS_HOST` 不被官方镜像识别——`wp-config-docker.php`
  只映射固定的一组 WORDPRESS_* 变量,其中没有 Redis 项;Redis Object Cache
  插件读的是 PHP 常量 `WP_REDIS_HOST`。改为经 `WORDPRESS_CONFIG_EXTRA` 注入。

违反本书自己规则的四处:

- 全书 21 处 `FROM ... as`(13 处在正文、8 处在 Dockerfile)用小写 as,会被
  `docker buildx build --check` 的 FromAsCasing 报
  `'as' and 'FROM' keywords' casing do not match`——而本书正是拿 `--check`
  当准绳(7.6:16、10.2:23),且自己另有 12 处已经写成大写 AS。统一为 AS,
  并把 7.17:174 那句"可以使用 `as` 来为某一阶段命名"一并改掉并附上检查项链接。
- 6.3:137 建议"可替换为 `httpd:latest`",而同文件 22 行之后就写着"不要使用
  `latest`,以保证部署的可重复性"。删去该建议。
- 7.6:253 写"多个 ENV 会创建多层",而 4.5:5 明确区分过:只改元数据的指令
  不新增文件系统层。ENV 正属于后者。改为"多出几条构建历史记录"。

核验方式的一点说明:查 Alpine 包是否存在时,我先用网页搜索接口做了一遍,
结果四个包名全部"命中"(包括本不该存在的那个)——那个页面会把查询词回显。
改用官方 APKINDEX 解包比对后才得到可信结论,两种方法交叉确认后才动手。
2026-09-04 15:01:00 -07:00
yeasy 659473e6d8 fix(demo): 三个配套示例目录与其章节漂移,其中两处带真实后果
章节里写着「完整的文件如下」,仓库里配套的实际文件却已经和正文对不上。
这类漂移比正文里的笔误更隐蔽——读者按目录跑起来的是另一份东西。

- `11_compose/demo/django/Dockerfile` 用的是 `ENV PYTHONUNBUFFERED 1` 这种
  空格旧写法,而 7.6 节写着绝对规则:「已被官方弃用……`docker buildx build
  --check` 会直接把它标出来。**一律用等号**」。这是全仓唯一一处违反(已扫过
  全部 md 与 11 个 Dockerfile)。同文件还有三处与 11.6 节不符:`FROM python:3`
  (章节是 3.12-slim)、`pip install` 缺 `--no-cache-dir`(章节专门列表讲了
  它的作用)、requirements 用 psycopg2 而章节表格写着「推荐使用 psycopg 3」。
  按 11.6 同步,现与章节代码块逐字节一致。
- `07_dockerfile/multistage_example/laravel/Dockerfile` 与 7.18 节差三处,
  两处有实质后果:`chmod -R 777 storage`(章节是 `chown www-data` + `775`)
  —— 而 18.5 节正拿 `777` 当"全员读写权限"的风险范例;以及 `COPY composer.json`
  漏掉了 `composer.lock`,正好破坏该章论证的可复现性。第三处 nginx 标签
  1.30 与全书 20 处 1.28 不一致(且章节自己的注释就推荐 1.28-alpine)。
  同步后与章节仅差章节独有的那行说明性注释。
- `11_compose/demo/wordpress/docker-compose.yml` 的 wordpress 服务**完全没有
  `volumes:`**,而 11.8 节专门加粗警告过「`volumes` 配置很重要!没有它,每次
  容器重启数据都会丢失」并声明了 `wp_data`。该 demo 恰好演示了章节警告的那个
  故障。另外还缺 `wp_net`、两个 container_name、`WORDPRESS_DB_NAME` 与
  `uploads.ini` 挂载。按章节同步,并补上章节 11.8.3 已给出内容的 `uploads.ini`
  (否则挂载会指向不存在的文件)。同步后 YAML 实测可解析,volumes 为
  db_data + wp_data。

`secrets/` 目录未补:它被 .gitignore 有意排除,demo 的 README 就是教读者
自己创建的,属于设计而非缺失。
2026-09-04 14:56:23 -07:00
yeasy a780127d48 fix(用词): 「其它」统一为「其他」(34 处 / 25 文件)
《现代汉语词典》与《中文技术文档写作风格指南》都以「其他」为规范词形;
本书基线是 90 处「其他」比 35 处「其它」,是集群里遗留最多的一本
(其余各书 0~4 处,blockchain_guide 已于 2026-08-05 统一过 47 处)。

其中 6 处在标题和目录上——`4.6 其它制作镜像的方式`、`第十七章 容器其它生态`、
`18.5 其它安全特性`——标题与 SUMMARY 条目**同批改写以保持一致**:
改动后 196 条目录名与各文件标题仍是 0 处不一致。

**`CHANGELOG.md` 里那一处刻意不动**:它是历史发布记录,改它等于改历史。

改动前后逐字符对称差:只有 34 个「它」变成「他」,无其他字符变化。
`check_project_rules` 202/202、`check_emphasis` 202/202、37 tests OK。
2026-08-24 13:18:05 -07:00
yeasy ef2625531d style: 含中文的括号统一为全角(336 处 / 110 文件)
全书此前是真·五五开:含中文的括号 336 处半角 : 336 处全角,而且**在同一文件
内混用**——`18_security/18.1_kernel_ns.md` 第 11/17/20 行写 `(如 runC)`,
第 31 行写 `(用户命名空间映射)`。这不是体例问题,是它自己跟自己不一致。

集群里其余 13 本都一边倒(llm_internals 5 : 1049、oc_guide 2 : 713、
forward_deployed_engineering_guide 0 : 108),blockchain_guide 已在 2026-08-05
按同一方向统一过 97 处,故取全角,而非另立新规。全角括号前后不留空格,
原先 `概念 (镜像、容器、仓库) 和` 两侧的空格一并收掉。

**纯拉丁内容的半角括号一个没动**——`新建一个层 (Layer)`、`项目 (project)`
保持原样:改动前后「半角且内容纯拉丁」的数量都是 **1163**,而「半角且含中文」
从 **336 变成 0**。

其余验证:改动前后各自抹掉全部空白与圆括号后**逐字节相同**(两侧均 19559 字符);
左右括号总数改动前后都是 399 : 399,证明没有吞括号也没有配错对。
`check_project_rules` 202/202、`check_emphasis` 202/202、37 tests OK、
根 `format_checker` 与 `validate_codeblocks` 干净、`git diff --check` 干净。
2026-08-24 13:13:23 -07:00
yeasy 33bca896b5 fix(11.4): COMPOSE_DEBUG=1 不是 Compose 的环境变量
11.4.2 让读者在 V2 里改用 `COMPOSE_DEBUG=1` 打开调试输出,但这个变量既不在官方
[Compose 环境变量清单](https://docs.docker.com/compose/how-tos/environment-variables/envvars/)
里(该页只有 COMPOSE_PROJECT_NAME、COMPOSE_FILE、COMPOSE_PROFILES … COMPOSE_PROGRESS
等 15 个),在 docker/compose 源码里也搜不到——照做不会有任何效果。

同时 `--verbose` 的定性收紧一档:源码 cmd/compose/compose.go 里它仍会
`logrus.SetLevel(logrus.TraceLevel)`,只是被 `MarkHidden("verbose")` 从 --help 里
藏起来了,并没有像 `--no-ansi` 那样被标 DEPRECATED,所以说"已弃用"不准确。

另:同节下一行的 `-v, --version` 经核实是对的,虽然官方文档的 global options 表里
没有它,但源码 `c.Flags().BoolVarP(&version, "version", "v", ...)` 确实注册了该短选项
(同样是 MarkHidden 才没进文档),故**未改动**。
2026-08-07 23:29:17 -07:00
yeasy 141fdc80bc fix(examples): 修正若干无法按原样执行的命令
* appendix/repo/nodejs.md:`docker build -t my-nodejs-app` 缺上下文参数,实际会
  报 "docker buildx build" requires exactly 1 argument;补 `.`。同文件 docker run
  示例里 `# -v "$ ":/usr/src/myapp \` 这一行的注释把自己的续行反斜杠也注掉了,加上
  紧跟的空行,命令在 `--name my-running-script` 处就结束、没有镜像名,后面几行变成
  独立的无效命令。该行内容与下一行的 --mount 重复,且 `"$ "` 已是残缺文本,删去。

* 06_repository/6.4:`openssl s_client -connect YourDomainName OR HostIP:443` 里的
  占位符带空格,shell 会切成三个参数,-connect 只收到 YourDomainName,openssl 直接
  报错;`docker login YourDomainName OR HostIP` 同理。改为一个变量。

* 08_data/8.2:`docker run -v $(pwd):/app -p 3000:3000 node npm run dev` 跑不起来
  ——官方 node 镜像没有设置 WORKDIR(docker-node 的 Dockerfile 里只有 ENTRYPOINT
  与 CMD),工作目录是 /,npm 找不到 /package.json。补 -w /app,顺手引号包住 $(pwd)
  并给出确定的标签(本书 4.1、7.10 都要求避免 latest)。

* 12_implementation/12.6:整段用的是 iproute2(ip link add / ip netns exec),中间
  却夹了一句 `brctl addif`。bridge-utils 在当前 Debian/Ubuntu/RHEL 默认不再安装,
  照抄会在这一行断掉;改成等价的 `ip link set A master docker0`。

* 14.1/14.2 的 `sysctl --system`、14.1 join 节点的 `systemctl enable/start
  containerd`、6.4 的 `systemctl restart docker` 都缺 sudo,而紧邻的行(sudo tee、
  14.1 第 47 行的 sudo systemctl restart containerd)都带。补齐。

* 15_etcd/demo/cluster/docker-compose.yml 仍留着顶层 `version: "3.6"`,Compose 会
  警告 obsolete;11.1 明写「新文件建议直接省略该字段」,15.3 正文内联的同一份文件
  也早已省略,只有磁盘上的 demo 落下了。删除后 YAML 仍可正常解析。

* 11.4:「对于 web 项目中的一个 db 容器,可能是 web_db」是 Compose V1 的下划线拼接,
  V2 起统一改用连字符,只有 --compatibility 才回到下划线。

* 附录四 CMD 一节四处写成 `CMD ['executable', 'param1']` 单引号,还说「我们建议任何
  服务镜像都使用这种形式」。exec 形式是 JSON,单引号解析不出来会退回 shell 形式,本书
  7.4 就把 `CMD ['node', 'server.js']` 明确标为「❌ 错误:单引号(JSON 不支持)」。
  一并把 `CMD ['PHP', '-a']` 的二进制名改回小写 php。
2026-08-07 23:26:36 -07:00
yeasy 08e981018e fix(content): 修正四处书内自相矛盾的技术断言
1. FROM「必须是第一条指令」(4.5、7.16、summary 三处)与本书 7.7.4「FROM 之前的
   ARG」整节直接冲突。官方 Dockerfile 参考写的是 "A Dockerfile must begin with a
   FROM instruction. This may be after parser directives, comments, and globally
   scoped ARGs",且 "ARG is the only instruction that may precede FROM"。三处
   一并改成「第一条构建指令」并点明例外。

2. 12 章小结把 USER Namespace 列进「默认启用」的一档,并写「容器 root ≠ 宿主机
   root」;而同章 12.2.2 明写 USER Namespace 默认**不**启用、需 userns-remap 显式
   开启,18.1 更直说「在默认情况下,容器内的 root 用户(UID=0)就是宿主机上的
   root 用户」。小结按正文口径改回——这条读反了会直接误判容器逃逸的风险面。

3. 11.5「目前支持三种日志驱动类型」是 Compose 早期文本的残留。官方支持 json-file、
   local、syslog、journald、gelf、fluentd、awslogs、splunk、etwlogs、gcplogs、
   none 共十余种,本书 19 章小结自己就列了六种。改为给出常见取值并链到官方清单。

4. 7.8 与 7.5 的示例注释建议 postgres:latest / redis:latest,而 4.1、7.10、
   7.16、7 章小结、4.5 全都要求避免 latest(7.8 同一文件第 177 行也写「避免
   latest」)。按全书口径改掉这两处。

另:ENV 的空格分隔旧写法(7.6 的「格式一」、附录四的 PG_MAJOR/PATH 示例)改为等号
形式并加注。BuildKit 的 LegacyKeyValueFormat 检查会报
"ENV key=value" should be used instead of legacy "ENV key value" format,
而本书 10.2 与 07 章 README 正是在推荐 docker buildx build --check。
2026-08-07 23:26:12 -07:00
yeasy ee0fbd7d38 fix(ci): attest releases and validate offline examples 2026-07-10 19:29:30 -07:00
yeasy daa6661b2b fix(ci): harden publishing and validate examples 2026-07-10 19:29:30 -07:00
yeasy 9fdffa9d91 fix(content): harden Docker practice guide 2026-06-16 21:23:21 -07:00
yeasy 01a6b2dccd fix(content): align compose demo Dockerfiles to COPY over ADD
The app and django compose demos used ADD for plain local files, but the
book's in-text versions of the same examples (11.3_usage.md, 11.6_django.md)
and its own guidance (7.2/7.3, appendix best_practices) all use COPY. Align
the demos with the documented practice.
2026-06-11 23:17:58 -07:00
yeasy 0cfd55af7b fix(content): repair Django tutorial crash and complete the hardening sweep
Follow-ups to the 9 secret-hardening commits (each verified against
docs.docker.com / vendor docs; one outright new bug found and fixed):

- 11.6: eb5e4397 changed settings.py to a hard os.environ lookup but the
  web service never receives POSTGRES_PASSWORD (only db does; DATABASE_URL
  is set but never read) -> step-6 'docker compose up' crashed with
  KeyError. Pass the var to web; harden the leftover literal password in
  the 配置详解 snippet that contradicted the new guidance two lines down;
  blank line after the inserted sentence (bold heading merged into the
  paragraph); dev/prod table no longer claims dev uses 明文 passwords
- 11.8: FAQ still told readers to check passwords in .env after the same
  file banned passwords in .env -> point at secrets/db_password.txt;
  backup sidecar env vars updated to tiredofit/db-backup 4.x interface
  (DB01_* + DB01_PASS_FILE + DB01_BACKUP_INTERVAL - the unprefixed DB_*
  names are ignored by current :latest; verified against upstream README)
- demo/wordpress: compose now references secrets files that ship nowhere
  -> add README with the creation commands from 11.8; demo/django: align
  with the hardened 11.6 (env-injected password, passed to web too)
- 04_image multistage demos: go build without go.mod fails on module-mode
  Go (reproduced by reviewer on go1.26) -> add 'go mod init helloworld'
  matching the 7.17 doc pattern in all three Dockerfiles
- 21.7: init script reworked init-db.sql -> init-db.sh per the official
  image's env-reading .sh hook - removes the baked 'secure_password' AND
  the CREATE DATABASE myappdb collision with POSTGRES_DB that aborted
  first-boot init (ON_ERROR_STOP); compose passes APP_DB_PASSWORD;
  microservices init.sql mount annotated schema-only (POSTGRES_USER:
  appuser would collide with CREATE USER); Dockerfile-redis healthcheck
  now authenticates via REDISCLI_AUTH read from redis.conf (plain
  redis-cli ping gets NOAUTH against requirepass - same class as the
  compose sibling eb5e4397 already fixed); dev-container dev/dev creds
  annotated local-only
- 19.3: Grafana admin password 'admin' sat directly under the newly added
  security warning -> env-injected like the rest of the stack
2026-06-10 12:06:57 -07:00
yeasy eb5e4397e8 docs: remove hardcoded compose secrets 2026-06-08 16:16:36 -07:00
yeasy 67d5fc775a fix(content): harden Compose credential examples 2026-06-04 01:02:59 -07:00
yeasy 1cdd3c582a fix(content): harden Docker examples 2026-06-01 10:33:50 -07:00
yeasy 094965e039 修复编辑问题:错别字/语病/术语/标点等 25 处(自动审校) 2026-05-31 22:20:50 -07:00
yeasy 3a9ee19d22 docs(content): refresh Kubernetes helper versions 2026-05-26 00:45:20 -07:00
yeasy 28c23d003e fix(content): harden Docker examples 2026-05-23 21:28:59 -07:00
yeasy 6a55219310 fix(11.3): use COPY (not ADD) in Flask/Redis intro Dockerfile
§7.3 of this book explicitly recommends COPY over ADD for simple
file copies ("在大多数情况下,你应该使用 COPY,而不是 ADD"). The intro
Compose example showed ADD without needing tar extraction or URL
download, contradicting the canonical guidance. Switched to COPY
so the first Dockerfile readers see matches the rule the book
teaches a few chapters later.
2026-05-23 21:27:01 -07:00
yeasy e17bef96d2 docs(content): update Compose and safety guidance 2026-05-21 20:13:39 -07:00
yeasy 2e625a3cdf fix(content): harden install and security guidance 2026-05-21 01:23:44 -07:00
yeasy d47afa7e75 docs: harden Docker practice security examples 2026-05-20 15:58:46 -07:00
yeasy 1b651e5f8c fix(content): refresh Docker and Kubernetes guidance 2026-05-20 09:16:36 -07:00
yeasy 58504e9316 fix(review-fixes): surgical content corrections from web-verified library deep review 2026-05-19 19:45:02 -07:00
yeasy 4075330dba Fix architecture mermaid and MySQL version 2026-05-19 18:43:11 -07:00
yeasy 9f481e88ca Fix go mod, Docker Hub rate limit, Compose verbose, docker debug, htpasswd security 2026-05-13 08:30:20 +00:00
yeasy 10381deee4 Add healthcheck to Rails Compose example 2026-05-03 05:23:12 +00:00
yeasy bf3107b775 Update MySQL 8.0 to 8.4 LTS, fix Trivy tag count 2026-05-02 15:22:58 +00:00
yeasy 16203c5018 Complete Dockerfile instruction reference list 2026-04-27 23:17:39 +00:00
yeasy 37e376d578 Fix mongosh, DCA price, compose healthcheck and cleanup 2026-04-27 14:17:57 +00:00
yeasy 84a801f3ac Document depends_on condition and healthcheck 2026-04-25 21:03:39 +00:00
yeasy 1e9cdeea3f Update Grafana to v13, add version notes 2026-04-25 15:50:13 +00:00
yeasy 515ba9f64a Add blank lines before lists per CommonMark 2026-04-25 15:13:27 +00:00
yeasy b3d1508310 Add new content and update versions 2026-04-19 22:35:33 -07:00
yeasy d81405a807 Update versions and fix stale data 2026-04-17 21:17:12 -07:00
yeasy f86e3567e8 Fix figure caption punctuation and table formatting 2026-04-13 18:37:00 -07:00
yeasy 2dacddb999 Fix figure caption format 2026-04-09 09:02:44 -07:00
yeasy e3e21e7a7d Refresh deployment guidance 2026-03-30 22:48:59 -07:00
yeasy 3bad07c41a 更新Docker安装、镜像、Dockerfile和Compose等文档内容 2026-03-29 11:40:34 -07:00
yeasy 85f76aa6d9 Fix guide issues 2026-03-28 18:24:46 -07:00
yeasy 63ce0dc3f5 Fix trailing whitespace 2026-03-27 22:20:39 -07:00
yeasy 76c2ae50fe Add blank lines around headers 2026-03-24 09:27:04 -07:00
yeasy 44b1307277 Remove blank lines after code block markers 2026-03-21 22:36:09 -07:00
yeasy 370949f226 Add blank lines before headers 2026-03-21 12:57:51 -07:00
yeasy 8d7541bed6 Convert bare URLs to markdown links 2026-03-16 23:28:44 -07:00
yeasy 696070cba9 Remove redundant English from headings 2026-03-16 22:34:38 -07:00
yeasy c02a8a41cd Update container runtime guidance 2026-03-16 20:49:00 -07:00
yeasy b9c63a5133 Polish Docker workflow formatting 2026-03-16 00:32:49 -07:00
yeasy 224e2738ce Replace straight quotes with curved quotes 2026-03-11 22:19:26 -07:00
yeasy 6abe4934e7 Fix figure captions, numbering, and heading level 2026-03-09 19:03:47 -07:00