
pypiserver是一个轻量级的PyPI兼容服务器,专为pip或easy_install设计,基于bottle框架开发,可从普通目录提供软件包服务。该Docker镜像封装了pypiserver的核心功能,支持上传/下载wheels、bdists、eggs及PGP签名文件,兼容pip、setuptools、twine等标准Python工具,无需复杂配置即可快速搭建私有PyPI仓库。
bash# 创建本地包目录 mkdir -p ~/pypi_packages # 启动基础pypiserver容器 docker run -d -p 8080:8080 -v ~/pypi_packages:/data/packages pypiserver/pypiserver:latest run -p 8080 /data/packages
创建htpasswd文件(需安装passlib):
bashpip install passlib htpasswd -sc ~/pypi_htpasswd.txt admin # 按提示输入密码
启动带认证的容器:
bashdocker run -d -p 8080:8080 \ -v ~/pypi_packages:/data/packages \ -v ~/pypi_htpasswd.txt:/data/htpasswd.txt \ pypiserver/pypiserver:latest \ run -p 8080 -P /data/htpasswd.txt -a update /data/packages
yamlversion: '3' services: pypiserver: image: pypiserver/pypiserver:latest ports: - "8080:8080" volumes: - ./packages:/data/packages - ./htpasswd.txt:/data/htpasswd.txt command: run -p 8080 -P /data/htpasswd.txt -a update,download /data/packages restart: always
| 参数 | 说明 | 示例 |
|---|---|---|
-p, --port | 服务端口 | -p 8080 |
-i, --interface | 监听地址 | -i 0.0.0.0 |
-a, --authenticate | 需要认证的操作(download/list/update) | -a update,download |
-P, --passwords | htpasswd认证文件路径 | -P /data/htpasswd.txt |
--disable-fallback | 禁用PyPI fallback | --disable-fallback |
--fallback-url | 自定义fallback地址 | --fallback-url https://mirrors.aliyun.com/pypi/simple/ |
-o, --overwrite | 允许覆盖已存在的包 | -o |
--health-endpoint | 自定义健康检查端点 | --health-endpoint /health |
临时使用
bashpip install --extra-index-url http://localhost:8080/simple/ 包名
永久配置(~/.pip/pip.conf)
ini[global] extra-index-url = http://localhost:8080/simple/ trusted-host = localhost # 非HTTPS时需要
ini[easy_install] index_url = http://localhost:8080/simple/
配置~/.pypirc:
ini[distutils] index-servers = local [local] repository: http://localhost:8080 username: admin # htpasswd中的用户名 password: 密码 # htpasswd中的密码
上传命令:
bashtwine upload --repository local dist/*
bashdocker run -d -p 8080:8080 \ -v ~/pypi_packages:/data/packages \ pypiserver/pypiserver:latest \ run --health-endpoint /health /data/packages
访问http://localhost:8080/health返回200 OK表示服务正常。
bashdocker run -d -p 8080:8080 \ -v ~/pypi_packages:/data/packages \ pypiserver/pypiserver:latest \ run --server-base-url /pypi /data/packages
此时访问地址为http://localhost:8080/pypi/simple/。
nginxserver { listen 80; server_name pypi.example.com; location / { proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
~/pypi_packages目录以防止数据丢失--backend cached-dir启用缓存更多详细信息请参考https://github.com/pypiserver/pypiserver%E3%80%82
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务