fix(content): harden install and security guidance

This commit is contained in:
yeasy
2026-05-21 01:23:44 -07:00
parent d47afa7e75
commit 2e625a3cdf
9 changed files with 27 additions and 28 deletions
+4 -3
View File
@@ -29,7 +29,7 @@
### 碰到网络问题无法 pull 镜像命令行指定 http\_proxy 无效
Docker 配置文件中添加 `export http_proxy="http://<PROXY_HOST>:<PROXY_PORT>"`之后重启 Docker 服务即可
先区分代理要作用在哪一层Docker daemon 拉取镜像时推荐在 `daemon.json` `proxies` 字段或 systemd drop-in 中配置 `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY`然后重启 Docker 服务Docker CLI构建过程和容器内应用的代理应分别使用 `~/.docker/config.json``--build-arg` `docker run --env` 配置不要把 `export http_proxy=...` 当作 `daemon.json` 内容写入
## 容器相关
@@ -79,8 +79,9 @@ $ docker run --network=my-net --ip=172.25.3.3 -itd --name=my-container busybox
* 创建镜像时 `Dockerfile` 要通过 `EXPOSE` 指定正确的开放端口
* 容器启动时指定 `PublishAllPort = true`
* 创建容器时用 `-p HOST_PORT:CONTAINER_PORT` `--publish` 显式发布端口例如 `docker run -p 8080:80 nginx`
* 只想把镜像声明的 `EXPOSE` 端口随机发布到宿主机端口时 `-P` / `--publish-all`之后通过 `docker ps` 查看实际端口
* `Dockerfile` 中的 `EXPOSE` 只是镜像元数据不会自动发布端口
### 可以在一个容器中同时运行多个应用进程么