Docker安裝pypiserver私服的方法步驟
1 簡介
Python開源包管理工具有pypiserver、devpi和Nexus等,pypiserver安裝部署比較簡單,性能也不錯。
搭建pypiserver私服,可以自己構(gòu)建鏡像,也可以使用官網(wǎng)的docker鏡像。
# Github地址
https://github.com/pypiserver/pypiserver
2 安裝
使用docker安裝pypiserver
# 下載包 docker pull pypiserver/pypiserver:v2.3.2
使用docker安裝鏡像
pypiserver支持使用.htpasswd設(shè)置用戶名和密碼。在目錄中/home/pypiserver/創(chuàng)建密鑰文件
# Ubuntu上安裝htpasswd的依賴包 sudo apt-get install apache2 apache2-utils # 生成密碼文件,root是用戶名(可根據(jù)需求自己設(shè)定),之后輸入密碼即可 htpasswd -sc /home/pypiserver/.htpasswd root # 返回值如下 New password: Re-type new password: Adding password for user root
創(chuàng)建容器
docker run -itd \ --restart always \ --name pypiserver \ -p 8080:8080 \ -v /home/pypiserver/.htpasswd:/data/.htpasswd \ -v /home/pypiserver/packages:/data/packages \ pypiserver/pypiserver:v2.3.2 run -P .htpasswd packages
訪問地址
# 系統(tǒng)地址
http://192.168.108.146:8080/
# 軟件包列表
http://192.168.108.146:8080/simple/


3 下載第三方包
單個下載numpy第三方包,建議不要再容器內(nèi)下載包(會在下載.tar.gz時報錯),推薦在宿主機(jī)的虛擬環(huán)境中下載。
# 進(jìn)入容器 docker exec -it pypiserver /bin/bash # 指定下載目錄packages pip download numpy -d ./packages --no-cache-dir # 指定第三方源,可以加快下載 pip download numpy -d ./packages -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir
批量下載第三方包
pip download -r requirements.txt -d ./packages
4 使用twine上傳自定義包
在Python環(huán)境中安裝twine
pip install twine
上傳自定義包
注意:dist目錄中是打包后的tar.gz或者whl文件,
# 上傳依賴包 twine upload --repository-url http://192.168.108.146:8080/ dist/*.tar.gz twine upload --repository-url http://192.168.108.146:8080/ dist/*.whl # 返回值 twine upload --repository-url http://192.168.108.146:8080/ ./*.whl Uploading distributions to http://192.168.108.146:8080/ Enter your username: root Enter your password: Uploading numpy-2.2.2-cp310-cp310-musllinux_1_2_x86_64.whl 100% ---------------------------------------- 18.2/18.2 MB ? 00:00 ? 174.0 MB/s
# 上傳tar.gz twine upload --repository-url http://localhost:8080 dist/numpy-2.2.2-cp310-cp310-musllinux_1_2_x86_64.tar.gz # 上傳.whl twine upload --repository-url http://localhost:8080 dist/numpy-2.2.2-cp310-cp310-musllinux_1_2_x86_64.whl
5 使用依賴包
安裝私有依賴包numpy。
# 注意不能單獨使用-i, --index-url安裝,盡量添加--trusted-host參數(shù) pip install -i http://192.168.108.146:8080/simple/ --extra-index-url http://192.168.108.146:8080/simple/ --trusted-host 192.168.108.146 numpy # 查看numpy pip search --index http://192.168.108.146:8080 numpy
到此這篇關(guān)于Docker安裝pypiserver私服的方法步驟的文章就介紹到這了,更多相關(guān)Docker安裝pypiserver私服內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Docker Registry搭建私有鏡像倉庫的實現(xiàn)方法
這篇文章主要介紹了Docker Registry搭建私有鏡像倉庫的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
解決docker pull報錯Get"https://registry-1.docker.io/v2
解決docker報錯Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)的方法是配置加速地址,添加相關(guān)配置后保存并重啟docker2026-03-03
以示例講解Clickhouse Docker集群部署以及配置
這篇文章主要介紹了Clickhouse Docker集群部署及配置,示例講解的非常詳細(xì),希望可以幫助到有需要的小伙伴2021-08-08
Docker consul的容器服務(wù)更新與發(fā)現(xiàn)的問題小結(jié)
這篇文章主要介紹了Docker consul的容器服務(wù)更新與發(fā)現(xiàn),講解了服務(wù)注冊與發(fā)現(xiàn)的基本概念講解,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下2021-08-08

