2024 年 docker 提示index.docker.io

发现 docker 提示以下错误:

复制代码
Error response from daemon: Get "https://index.docker.io/v1/search?q=nginx&n=25": dialing index.docker.io:443 container via direct connection because  has no HTTPS proxy: connecting to index.docker.io:443: dial tcp 96.44.137.28:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

配置阿里源后还是报错,尝试 docker info 命令发现配置已经生效,但就是错。更换其它国内源清华源、网易源仍然不行。

最后发现目前很多 docker hub 都关闭了,阿里源也只能使用在阿里产品范围内。所以要解决这个问就得自己搭建个私有 docker hub。


搭建私有 Docker Hub 的步骤如下:

1. 准备环境

  • 服务器:Linux 。
  • Docker:安装 Docker。

2. 选择私有仓库工具

常用的私有 Docker 仓库工具包括:

  • Docker Registry:官方提供的轻量级工具。
  • Harbor:企业级工具,提供更多功能。

3. 使用 Docker Registry 搭建私有仓库

3.1 创建配置文件

创建 config.yml 文件,配置如下:

复制代码
version: 0.1
log:
  fields:
    service: registry
storage:
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3
3.2 启动 Docker Registry

使用以下命令启动:

复制代码
docker run -d \
  -p 5000:5000 \
  --name registry \
  -v $(pwd)/config.yml:/etc/docker/registry/config.yml \
  -v /var/lib/registry:/var/lib/registry \
  registry:2
3.3 测试私有仓库

推送镜像到私有仓库:

复制代码
docker tag my-image localhost:5000/my-image
docker push localhost:5000/my-image

拉取镜像:

复制代码
docker pull localhost:5000/my-image

4. 使用 Harbor 搭建私有仓库

4.1 下载 Harbor

从 Harbor GitHub 下载安装包并解压。

4.2 配置 Harbor

编辑 harbor.yml 文件,设置主机名、端口和数据存储路径。

4.3 安装 Harbor

运行安装脚本:

复制代码
sudo ./install.sh
4.4 访问 Harbor

通过浏览器访问 http://<your-hostname>,使用默认账户 admin 和密码 Harbor12345 登录。

4.5 推送和拉取镜像

推送镜像:

复制代码
docker tag my-image <your-harbor-host>/my-project/my-image
docker push <your-harbor-host>/my-project/my-image

拉取镜像:

复制代码
docker pull <your-harbor-host>/my-project/my-image

我是栈江湖,如果你喜欢此文章,不要忘记点赞+关注

相关推荐
帝国辉耀11 天前
docker、docker daemon、k8s、dockershim、containerd之间的关系
docker·容器·kubernetes
明明跟你说过1 天前
【k8s】资源限制管理:Namespace、Deployment与Pod的实践
运维·docker·云原生·容器·kubernetes·k8s
2301_794333911 天前
实验室服务器配置|通过Docker实现Linux系统多用户隔离与安全防控
linux·服务器·docker·实验室
JCGKS1 天前
Docker|“ssh: connect to host xxx.xxx.xxx.xxx port 8000: Connection refused“问题解决
docker·ssh·端口·listen·tcp三次握手
惜.己1 天前
Docker启动失败 Failed to start Docker Application Container Engine.
spring cloud·docker·eureka
scugxl1 天前
centos7 docker离线安装
运维·docker·容器
计算机小手1 天前
AI 驱动数据分析:开源 SQLBot 项目探索,基于大模型和 RAG 实现精准问数与图表挖掘
经验分享·docker·开源软件
AI大模型1 天前
基于Docker+DeepSeek+Dify :搭建企业级本地私有化知识库超详细教程
docker·llm·deepseek
张璐月1 天前
go docker-compose启动前后端分离项目 踩坑之旅
开发语言·docker·golang
剑客的茶馆1 天前
新服务器从0开始搭配Ubuntu+Conda+Docker+Dify
服务器·ubuntu·docker·conda·dify