Skip to content

Conversation

@Masterain98
Copy link

📚 新增和改变

在授权凭据的提供商中增加了一个 Docker 宿主机,允许那些通过 Docker 运行 Certimate 的用户以 SSH 的方式更加方便地连接到 Docker 宿主机。本质仍然是 SSH 连接,但允许那些不熟悉 Docker 的用户更容易使用。

在使用 Dokcer 运行的时候需要增加 add-host 参数:

docker build -t certimate:dev .
docker run -p 8090:8090 --add-host=host.docker.internal:host-gateway certimate:dev

同样,在 docker-compose.yml 配置文件中增加 extra_hosts 也可以使该改变生效:

version: "3.0"
services:
  certimate:
    image: certimate/certimate:latest
    container_name: certimate
    ports:
      - 8090:8090
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - ./data:/app/pb_data
    restart: unless-stopped
    extra_hosts:
      - "host.docker.internal:host-gateway"

✨动机

  1. 虽然可以通过目录挂载的方式将宿主机上的目录挂载到 certimate 容器上,但如果宿主机上还运行着 nginx 服务器,则还是得连接上去执行 service nginx reload 之类的命令。所以目录挂载有用,但相比 SSH 作用有限。
  2. 使用 docker compose 运行包括 certimate 在内的程序是我的习惯,除非特别指定,否则 Docker 会为这个 stack 创建一个单独的网络,当需要从容器内连接到宿主机时,得先查一下容器的 IP 段才行。
  3. 对于不熟悉 Docker 的用户(比如 failed to deploy certificate #923 的作者),这是或许是一个更容易的部署方式。

👩‍💻 截图

对于 Docker 容器环境

image image image

对于非 Docker 环境

image image
Copilot Summary This pull request introduces support for Docker host access as a provider, enabling the system to detect and utilize the Docker host address for certificate deployment and management. It also adds backend and frontend mechanisms for environment detection and improves the user experience by auto-filling Docker host information in relevant forms. The changes span backend service registration, environment detection utilities, API endpoints, and UI integration.

Backend: Docker Host Provider Support

  • Added new provider types for Docker Host in internal/domain/provider.go and registered them in both certificate application and deployment workflows, allowing Docker Host to be used similarly to SSH for ACME challenges and deployments. [1] [2] [3] [4] [5] [6] [7]

Backend: Environment Detection and API

  • Implemented a utility (pkg/utils/netutil/dockerhost.go) to resolve the Docker host address, with tests for various scenarios. [1] [2]
  • Added a new EnvironmentService and REST handler to expose environment information (specifically Docker host reachability and address) via /api/system/environment. [1] [2] [3] [4] [5] [6]

Frontend: Environment Awareness and Docker Host Integration

  • Created a frontend API call to fetch environment information and a Zustand store to manage it.
  • Updated the access form to fetch environment info on mount, and integrated a new AccessConfigFieldsProviderDockerHost component that auto-fills the Docker host address if available. [1] [2] [3] [4] [5] [6]
  • Enhanced the SSH access config form to allow disabling the host field and hiding jump servers, supporting `the Docker Host use case. [1] [2] [3]

Infrastructure: Docker Compose

  • Updated the Docker Compose configuration to ensure the container can resolve host.docker.internal, improving Docker host detection reliability.

- Updated compatibility in workflow
- Hided jump server option in configuration page
@fudiwei
Copy link
Member

fudiwei commented Nov 4, 2025

感谢贡献代码。但该 PR 不会被合并。

host-gateway 这一特性对 docker 版本有限制,且在 Linux/macOS 平台表现不一致,我无法预估此变更是否对现有用户造成影响,因此不会被合并。

P.S. 不过该方案可以被纳入到 FAQ 中,供用户参考。

@fudiwei fudiwei closed this Nov 4, 2025
@fudiwei fudiwei added wontfix This will not be worked on and removed pr: waiting for review labels Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants