mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-10 08:27:25 +00:00
fix(content): remove demo registry credential
This commit is contained in:
@@ -13,6 +13,7 @@ node_modules/
|
||||
package-lock.json
|
||||
|
||||
docker-compose.override.yml
|
||||
06_repository/demo/auth/nginx.htpasswd
|
||||
|
||||
# Editor configs
|
||||
.obsidian/
|
||||
|
||||
@@ -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 文件
|
||||
|
||||
@@ -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.
|
||||
@@ -1,2 +0,0 @@
|
||||
username:$2y$05$TRWvCC6ilpKpY3ICifw32Ok3.8SpG3etq8O5WGdCm9wvyDhtSbRgy
|
||||
|
||||
Reference in New Issue
Block a user