Files
chill_notes/Docker/Rancher和Agent同主机运行.md
2026-04-21 20:01:46 +08:00

56 lines
1.2 KiB
Markdown
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 在同一主机运行 Rancher Server 和 Agent
## 背景
当单个节点既作为 Rancher Server 又作为被管理的集群节点时,会有端口冲突:
- Rancher Server 容器默认映射:`80``443`
- Rancher Agent 部署的 Ingress Controller 也使用:`80``443`
## 解决方案
修改 Rancher 容器的主机端口映射,避免冲突。
## 操作步骤
### 1. 停止现有 Rancher 容器
```bash
docker stop rancher
docker rm rancher
```
### 2. 使用修改后的端口重新启动
```bash
docker run -d --restart=unless-stopped \
-p 8080:80 -p 8443:443 \
-v <主机路径>:/var/lib/rancher/ \
rancher/rancher:latest
```
### 端口映射对照
| 原端口 | 新端口 | 说明 |
|--------|--------|------|
| 80 | 8080 | HTTP 入口 |
| 443 | 8443 | HTTPS 入口 |
### 3. 访问 Rancher
启动后通过新端口访问:
- HTTP`http://<主机IP>:8080`
- HTTPS`https://<主机IP>:8443`
## 注意事项
> ⚠️ **不建议在生产环境中这样使用**,仅适合开发/演示环境。
生产环境建议:
- Rancher Server 单独部署
- 管理节点和 workload 节点分开
---
> 参考:[Rancher 官方文档](https://docs.rancher.cn/rancher2x/faqs/important-issue.html)