mirror of
https://github.com/dqzboy/Docker-Proxy.git
synced 2026-01-12 16:25:42 +08:00
docs: README.md
This commit is contained in:
140
Issue/issue.md
140
Issue/issue.md
@@ -131,8 +131,8 @@ docker pull nginx
|
||||
```
|
||||
|
||||
#### 11、如何配置才能让数据不保留到磁盘中?
|
||||
- [x] **已知问题:** 默认使用的存储系统为`filesystem` 使用本地磁盘存储注册表文件
|
||||
- [x] **解决方案:** 修改对应Registry的配置,将`Storage driver` 存储驱动改为 `inmemory`,⚠️ 注意:此存储驱动程序不会在运行期间保留数据。这就是为什么它只适合测试。切勿在生产中使用此驱动程序。
|
||||
- [x] **已知问题:** 默认使用的存储驱动为`filesystem` 使用本地磁盘存储注册表文件
|
||||
- [x] **解决方案:** 修改对应Registry的配置,将`Storage driver` 存储驱动改为 `inmemory`,⚠️ 注意:此存储驱动程序不会在运行期间保留数据。
|
||||
|
||||
|
||||
#### 12、关于Docker Hub免费拉取政策再次变更后的解决方案?
|
||||
@@ -144,139 +144,7 @@ docker pull nginx
|
||||
# username 输入docker hub账号,password 输入对应账号密码
|
||||
proxy:
|
||||
remoteurl: https://registry-1.docker.io
|
||||
username:
|
||||
password:
|
||||
username: [username]
|
||||
password: [password]
|
||||
ttl: 168h
|
||||
```
|
||||
|
||||
|
||||
#### 13、[项目已实现]解决国内服务器上hubcmdui无法使用http代理请求
|
||||
简单的讲,需要解决两个问题:
|
||||
1. dns污染,请自行搭建smartdns服务
|
||||
2. 修改axios.get相关代码
|
||||
|
||||
亦可使用socket5方式,为了代理方案一致性,仅在pr中介绍
|
||||
|
||||
```bash
|
||||
# 拉取代码
|
||||
git clone https://github.com/dqzboy/Docker-Proxy.git
|
||||
# 前往文件夹,根据自己使用的代理情况,修改相应的代码
|
||||
cd Docker-Proxy/hubcmdui/
|
||||
```
|
||||
|
||||
关键生效的代码:
|
||||
```js
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
// 如果环境变量设置https_proxy则使用该代理
|
||||
const proxyUrl = process.env.https_proxy || process.env.HTTPS_PROXY;
|
||||
const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined;
|
||||
|
||||
... ...
|
||||
const response = await axios.get(`${DOCKER_HUB_API}/search/repositories`, {
|
||||
params: {
|
||||
query: term,
|
||||
page,
|
||||
page_size: limit
|
||||
},
|
||||
httpsAgent: agent, // 使用 HttpsProxyAgent 作为http proxy
|
||||
proxy: false, // 不使用 axios 自身代理
|
||||
timeout: 10000
|
||||
});
|
||||
... ...
|
||||
|
||||
```
|
||||
|
||||
需要修改使用了`axios.get`的三个文件:
|
||||
```bash
|
||||
vim routes/dockerhub.js
|
||||
vim compatibility-layer.js
|
||||
# 下面这个文件好像没调用,可以不修改
|
||||
vim services/dockerHubService.js
|
||||
```
|
||||
|
||||
解决误删的文件,当前仓库并不存在所需的`const { executeOnce } = require('../lib/initScheduler');`文件,而作者制作的镜像中存在,可能是误删了
|
||||
```bash
|
||||
$ mkdir Docker-Proxy/lib
|
||||
# 将所需文件放入该lib文件夹,从dockerhub中的镜像获取
|
||||
initScheduler.js
|
||||
logFilter.js
|
||||
logger.js
|
||||
systemInit.js
|
||||
utils.js
|
||||
```
|
||||
|
||||
还需要修改`Dockerfile`,补充需要的库
|
||||
```bash
|
||||
vim Docker-Proxy/Dockerfile
|
||||
```
|
||||
内容如下:
|
||||
```dockerfile
|
||||
FROM node:lts-alpine
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
# 复制项目文件到工作目录
|
||||
COPY hubcmdui/ .
|
||||
# 安装项目依赖
|
||||
RUN npm install
|
||||
# 推荐更新到最新版本axios,不更新好像也行,推荐更新
|
||||
RUN npm install axios@latest
|
||||
# 安装所需库
|
||||
RUN npm install https-proxy-agent
|
||||
# 暴露应用程序的端口
|
||||
EXPOSE 3000
|
||||
# 运行应用程序
|
||||
CMD ["node", "server.js"]
|
||||
```
|
||||
制作镜像并尝试启动
|
||||
```bash
|
||||
$ cd Docker-Proxy
|
||||
$ docker build --no-cache -f Dockerfile -t dqzboy/hubcmd-ui:test .
|
||||
```
|
||||
|
||||
接下来编辑`docker-compose.yaml`,设置dns,添加域名解析的ip,使用的http代理
|
||||
```bash
|
||||
$ cd Docker-Proxy/hubcmdui
|
||||
|
||||
$ vim docker-compose.yaml
|
||||
|
||||
services:
|
||||
## HubCMD UI
|
||||
hubcmd-ui:
|
||||
container_name: hubcmd-ui
|
||||
image: dqzboy/hubcmd-ui:test
|
||||
restart: always
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /data/registry-proxy/hubcmdui/data:/app/data
|
||||
ports:
|
||||
- 30080:3000
|
||||
dns:
|
||||
# 如果使用http代理,必须要处理dns解析过慢的情况
|
||||
# 可以尝试自建dns服务器/smartdns
|
||||
# 推荐参考上面的研究使用socket5代理
|
||||
- smartdns_server_ip
|
||||
environment:
|
||||
- http_proxy=http://http_proxy_url:http_proxy_port
|
||||
- https_proxy=http://http_proxy_url:http_proxy_port
|
||||
# 日志配置
|
||||
- LOG_LEVEL=DEBUG # 可选: TRACE, DEBUG, INFO, SUCCESS, WARN, ERROR, FATAL
|
||||
- SIMPLE_LOGS=true # 启用简化日志输出,减少冗余信息
|
||||
# - DETAILED_LOGS=false # 默认关闭详细日志记录(请求体、查询参数等)
|
||||
# - SHOW_STACK=false # 默认关闭错误堆栈跟踪
|
||||
# - LOG_FILE_ENABLED=true # 是否启用文件日志,默认启用
|
||||
# - LOG_CONSOLE_ENABLED=true # 是否启用控制台日志,默认启用
|
||||
# - LOG_MAX_SIZE=10 # 单个日志文件最大大小(MB),默认10MB
|
||||
# - LOG_MAX_FILES=14 # 保留的日志文件数量,默认14个
|
||||
```
|
||||
重新启动容器,尝试解析能正常访问输出
|
||||
```bash
|
||||
$ docker-compose -f docker-compose.yaml up -d --force-recreate
|
||||
# 查看日志
|
||||
$ docker logs hubcmd-ui -f
|
||||
# 本地测试
|
||||
$ curl "http://localhost:30080/api/dockerhub/search?term=redis&page=1"
|
||||
# 删除容器
|
||||
$ docker-compose -f docker-compose.yaml down
|
||||
# 配置文件在本地的位置
|
||||
$ ls /data/registry-proxy/hubcmdui/data
|
||||
```
|
||||
|
||||
39
README.md
39
README.md
@@ -64,17 +64,15 @@
|
||||
---
|
||||
|
||||
## 🔨 功能
|
||||
- [x] 一键部署Docker镜像代理服务的功能,支持基于官方Docker Registry的镜像代理.
|
||||
- [x] 支持多个镜像仓库的代理,包括Docker Hub、GitHub Container Registry(ghcr.io)、Quay Container Registry(quay.io)、Kubernetes Container Registry(k8s.gcr.io)、Microsoft Container(mcr.microsoft.com)、Elastic Stack(docker.elastic.co)
|
||||
- [x] 自动检查并安装所需的依赖软件,如Docker\Compose、Nginx\Caddy等,并确保系统环境满足运行要求
|
||||
- [x] 根据你所选择部署的WEB反代服务,自动渲染对应的Nginx或Caddy服务配置
|
||||
- [x] 支持配置账号密码登入Docker Hub,可访问 Docker Hub 上的私有镜像同时解决Docker Hub的下载频率限制 [配置参考](https://github.com/dqzboy/Docker-Proxy/blob/main/Issue/issue.md#12%E5%85%B3%E4%BA%8Edocker-hub%E5%85%8D%E8%B4%B9%E6%8B%89%E5%8F%96%E6%94%BF%E7%AD%96%E5%86%8D%E6%AC%A1%E5%8F%98%E6%9B%B4%E5%90%8E%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88)
|
||||
- [x] 支持自定义配置代理缓存时间(PROXY_TTL)、支持配置IP黑白名单,防止恶意攻击行为
|
||||
- [x] 提供了服务管理、配置管理、服务卸载、认证授权等功能,方便用户进行日常管理和维护
|
||||
- [x] 一键部署Docker镜像代理服务,支持多个上游镜像仓库代理,如`Docker Hub`、`ghcr`、`quay`、`k8s`、`mcr.microsoft.com`、`docker.elastic.co`等
|
||||
- [x] 自动检查安装软件依赖,如Docker\Compose、Nginx\Caddy等
|
||||
- [x] 支持选择自动部署等反代服务,自动渲染对应Nginx或Caddy反代配置
|
||||
- [x] 支持配置账号密码登入Docker Hub,可下载私有镜像并解决Docker Hub镜像下载频率限制 [配置参考](https://github.com/dqzboy/Docker-Proxy/blob/main/Issue/issue.md#12%E5%85%B3%E4%BA%8Edocker-hub%E5%85%8D%E8%B4%B9%E6%8B%89%E5%8F%96%E6%94%BF%E7%AD%96%E5%86%8D%E6%AC%A1%E5%8F%98%E6%9B%B4%E5%90%8E%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88)
|
||||
- [x] 支持自定义配置代理缓存时间(PROXY_TTL)、支持配置IP黑/白名单,防止恶意攻击行为
|
||||
- [x] 提供服务管理、配置管理、服务卸载、认证授权等功能,方便后期日常运维管理
|
||||
- [x] 支持一键配置本机Docker代理和容器服务代理(HTTP_PROXY),仅支持http
|
||||
- [x] 支持国内服务器一键部署,解决国内环境无法安装Docker\Compose服务难题
|
||||
- [x] 支持主流Linux发行版操作系统,例如Centos、Ubuntu、Rocky、Debian、Rhel等,支持主流ARCH架构下部署,包括linux/amd64、linux/arm64
|
||||
- [x] HubCMD-UI服务,面板展示、镜像搜索、文档教程、容器管理、容器监控、网络测试、用户中心等功能
|
||||
- [x] HubCMD-UI服务,面板展示、镜像搜索、文档教程、容器管理、容器监控告警等功能
|
||||
|
||||
## 📦 部署
|
||||
### 通过项目脚本部署
|
||||
@@ -159,23 +157,12 @@ docker logs -f [容器ID或名称]
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
### 前缀替换说明
|
||||
### 使用教程
|
||||
<details>
|
||||
<summary><strong>点击查看</strong></summary>
|
||||
<div>
|
||||
|
||||
| 源站 | 替换为 | 平台 |
|
||||
|-------|---------------|----------|
|
||||
| docker.io | hub.your_domain_name | docker hub
|
||||
| gcr.io | gcr.your_domain_name | Google Container Registry
|
||||
| ghcr.io | ghcr.your_domain_name | GitHub Container Registry
|
||||
| k8s.gcr.io | k8s-gcr.your_domain_name | Kubernetes Container Registry
|
||||
| registry.k8s.io | k8s.your_domain_name | Kubernetes's container image registry
|
||||
| quay.io | quay.your_domain_name | Quay Container Registry
|
||||
| mcr.microsoft.com | mcr.your_domain_name | Microsoft Container Registry
|
||||
| docker.elastic.co | elastic.your_domain_name | Elastic Stack
|
||||
| nvcr.io | nvcr.your_domain_name | NVIDIA Container Registry
|
||||
[使用教程](https://dqzboy.github.io/docs/pages/install.html#%E2%9C%A8-%E4%BD%BF%E7%94%A8)
|
||||
|
||||
</details>
|
||||
|
||||
@@ -270,6 +257,14 @@ docker logs -f [容器ID或名称]
|
||||
|
||||
[docker-registry-browser](https://github.com/klausmeyer/docker-registry-browser)
|
||||
|
||||
---
|
||||
|
||||
[NodeSupport](https://github.com/NodeSeekDev/NodeSupport)赞助了本项目
|
||||
|
||||
<a href="https://yxvm.com/" target="_blank">
|
||||
<img src="https://cdn.jsdelivr.net/gh/dqzboy/Images/dqzboy-proxy/yxvm.png" width="300" height="200">
|
||||
</a>
|
||||
|
||||
## License
|
||||
Docker-Proxy is available under the [Apache 2 license](./LICENSE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user