Skip to content

Commit ea26f96

Browse files
committed
fix(content): remove demo registry credential
1 parent 30f26d9 commit ea26f96

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ node_modules/
1313
package-lock.json
1414

1515
docker-compose.override.yml
16+
06_repository/demo/auth/nginx.htpasswd
1617

1718
# Editor configs
1819
.obsidian/

06_repository/6.3_registry_auth.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ $ openssl x509 -req -days 750 -in "site.csr" -sha256 \
7070
-CA "root-ca.crt" -CAkey "root-ca.key" -CAcreateserial \
7171
-out "docker.domain.com.crt" -extfile "site.cnf" -extensions server
7272
```
73+
74+
配套 demo 中的 [`ssl/README.md`](demo/ssl/README.md) 只保留本地生成证书的占位说明,真实私钥和证书不应提交到仓库。
7375
这样已经拥有了 `docker.domain.com` 的网站 SSL 私钥 `docker.domain.com.key` 和 SSL 证书 `docker.domain.com.crt` 及 CA 根证书 `root-ca.crt`
7476

7577
新建 `ssl` 文件夹并将 `docker.domain.com.key` `docker.domain.com.crt` `root-ca.crt` 这三个文件移入,删除其他文件。
@@ -101,7 +103,7 @@ auth:
101103
realm: basic-realm
102104
path: /etc/docker/registry/auth/nginx.htpasswd
103105
http:
104-
addr: :443
106+
addr: :5000
105107
host: https://docker.domain.com
106108
headers:
107109
X-Content-Type-Options: [nosniff]
@@ -130,6 +132,7 @@ $ docker run --rm \
130132
> 将上面的 `username` `password` 替换为你自己的用户名和密码。
131133
>
132134
> **安全提示**:上述命令会将密码明文暴露在 shell 历史记录和进程列表中。生产环境建议使用交互式方式输入密码(不带 `-b` 参数),或通过环境变量/文件传入。
135+
> 配套 demo 的 [`auth/README.md`](demo/auth/README.md) 仅说明本地生成步骤,生成的 `auth/nginx.htpasswd` 已被忽略,不应提交。
133136
134137
> **版本说明**:使用 `httpd:2.4-alpine` 基于 Apache 2.4 的精简镜像。如需其他版本,可替换为 `httpd:latest` 或指定具体版本号如 `httpd:2.4.58-alpine`
135138
@@ -142,7 +145,7 @@ services:
142145
registry:
143146
image: registry:2
144147
ports:
145-
- "443:443"
148+
- "443:5000"
146149
volumes:
147150
- ./:/etc/docker/registry
148151
- registry-data:/var/lib/registry
@@ -151,6 +154,8 @@ volumes:
151154
registry-data:
152155
```
153156
157+
本书配套的 `06_repository/demo/` 也采用同样约定:容器内 registry 监听 `:5000`,宿主机通过 `443:5000` 暴露 HTTPS 服务。这样可以避免在容器内占用特权端口,同时仍让客户端使用 `https://docker.domain.com` 访问。
158+
154159
> **版本说明**:Compose 配置中明确指定 `registry:2` 版本。生产环境建议固定版本号(如 `registry:2.8.3`)而非使用 `latest`,以保证部署的可重复性。
155160

156161
### 6.3.5 修改 Hosts 文件

06_repository/demo/auth/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Generated Authentication File
2+
3+
Run the `htpasswd` command in section 6.3.3 to generate `nginx.htpasswd` locally before starting the demo registry.
4+
5+
Do not commit generated password hashes.

06_repository/demo/auth/nginx.htpasswd

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)