fix(content): remove demo registry credential

This commit is contained in:
yeasy
2026-05-25 01:13:10 -07:00
parent 30f26d9195
commit ea26f96297
4 changed files with 13 additions and 4 deletions
+1
View File
@@ -13,6 +13,7 @@ node_modules/
package-lock.json
docker-compose.override.yml
06_repository/demo/auth/nginx.htpasswd
# Editor configs
.obsidian/
+7 -2
View File
@@ -70,6 +70,8 @@ $ openssl x509 -req -days 750 -in "site.csr" -sha256 \
-CA "root-ca.crt" -CAkey "root-ca.key" -CAcreateserial \
-out "docker.domain.com.crt" -extfile "site.cnf" -extensions server
```
配套 demo 中的 [`ssl/README.md`](demo/ssl/README.md) 只保留本地生成证书的占位说明真实私钥和证书不应提交到仓库
这样已经拥有了 `docker.domain.com` 的网站 SSL 私钥 `docker.domain.com.key` SSL 证书 `docker.domain.com.crt` CA 根证书 `root-ca.crt`
新建 `ssl` 文件夹并将 `docker.domain.com.key` `docker.domain.com.crt` `root-ca.crt` 这三个文件移入删除其他文件
@@ -101,7 +103,7 @@ auth:
realm: basic-realm
path: /etc/docker/registry/auth/nginx.htpasswd
http:
addr: :443
addr: :5000
host: https://docker.domain.com
headers:
X-Content-Type-Options: [nosniff]
@@ -130,6 +132,7 @@ $ docker run --rm \
> 将上面的 `username` `password` 替换为你自己的用户名和密码
>
> **安全提示**上述命令会将密码明文暴露在 shell 历史记录和进程列表中生产环境建议使用交互式方式输入密码不带 `-b` 参数或通过环境变量/文件传入
> 配套 demo [`auth/README.md`](demo/auth/README.md) 仅说明本地生成步骤生成的 `auth/nginx.htpasswd` 已被忽略不应提交
> **版本说明**使用 `httpd:2.4-alpine` 基于 Apache 2.4 的精简镜像如需其他版本可替换为 `httpd:latest` 或指定具体版本号如 `httpd:2.4.58-alpine`
@@ -142,7 +145,7 @@ services:
registry:
image: registry:2
ports:
- "443:443"
- "443:5000"
volumes:
- ./:/etc/docker/registry
- registry-data:/var/lib/registry
@@ -151,6 +154,8 @@ volumes:
registry-data:
```
本书配套的 `06_repository/demo/` 也采用同样约定容器内 registry 监听 `:5000`宿主机通过 `443:5000` 暴露 HTTPS 服务这样可以避免在容器内占用特权端口同时仍让客户端使用 `https://docker.domain.com` 访问
> **版本说明**Compose 配置中明确指定 `registry:2` 版本生产环境建议固定版本号 `registry:2.8.3`而非使用 `latest`以保证部署的可重复性
### 6.3.5 修改 Hosts 文件
+5
View File
@@ -0,0 +1,5 @@
# Generated Authentication File
Run the `htpasswd` command in section 6.3.3 to generate `nginx.htpasswd` locally before starting the demo registry.
Do not commit generated password hashes.
-2
View File
@@ -1,2 +0,0 @@
username:$2y$05$TRWvCC6ilpKpY3ICifw32Ok3.8SpG3etq8O5WGdCm9wvyDhtSbRgy