docker镜像库在哪
Docker 镜像库(或称为 Docker 仓库)主要有以下几种类型和位置,根据您的需求可以选择不同的来源:
1. 公共镜像库
Docker Hub (默认官方库)
- 地址: https://hub.docker.com
- 特点:
- Docker 官方维护的公共镜像库,包含大量官方(如
nginx
、mysql
)和社区镜像。
- 默认拉取地址为
docker.io/library/镜像名
(例如 docker pull nginx
等价于 docker pull docker.io/library/nginx
)。
- 免费账户有拉取次数限制(匿名用户 100 次/6 小时,认证后 200 次/6 小时)。
其他公共库
- Red Hat Quay: https://quay.io
- GitHub Container Registry (GHCR): https://ghcr.io
- Google Container Registry (GCR): https://gcr.io
- Amazon ECR Public: https://gallery.ecr.aws
2. 私有镜像库
自建私有库
- Docker Registry (开源):
- 通过 Docker 官方提供的
registry
镜像快速部署:
bash
docker run -d -p 5000:5000 --name my-registry registry:2
- 镜像地址格式:
localhost:5000/镜像名
(需配置 HTTPS 或信任 HTTP 仓库)。
云服务商提供的私有库
- Amazon ECR: https://aws.amazon.com/ecr/
- Google Artifact Registry: https://cloud.google.com/artifact-registry
- Azure Container Registry (ACR): https://azure.microsoft.com/en-us/products/container-registry/
- 阿里云容器镜像服务: https://www.aliyun.com/product/acr
3. 企业内部镜像库
- Nexus Repository: 支持 Docker 镜像存储(需配置 Docker 仓库功能)。
- Harbor: 企业级开源镜像仓库(推荐),支持权限管理、漏洞扫描等。
4. 如何指定镜像库地址?
- 拉取镜像时显式指定仓库地址:
bash
docker pull quay.io/bitnami/nginx # 从 Quay.io 拉取
docker pull ghcr.io/username/image # 从 GitHub 拉取
- 推送镜像到私有库:
bash
docker tag my-image localhost:5000/my-image
docker push localhost:5000/my-image
5. 配置镜像加速器(国内用户)
国内访问 Docker Hub 可能较慢,可配置镜像加速器(如阿里云、腾讯云):
1. 修改 Docker 配置文件 /etc/docker/daemon.json
:
json
{
"registry-mirrors": ["https://<你的加速器地址>.mirror.aliyuncs.com"]
}
2. 重启 Docker 服务:
bash
sudo systemctl restart docker
常见问题
- 权限问题:私有库需先登录:
bash
docker login registry.example.com
- TLS 证书问题:自建仓库若使用 HTTP 需在客户端配置信任(生产环境建议 HTTPS)。
如果需要更具体的场景帮助(如自建仓库或企业级方案),可以进一步说明需求!