社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  docker

如何使用jenkins pipline步骤在docker映像中安装pip?

tiagosilva • 7 年前 • 2253 次点击  

我有这个 文档文件 :

FROM python:3.7

CMD ["/bin/bash"]

而这 詹金斯档案 :

pipeline {
agent {
    dockerfile {
        filename 'Dockerfile'
    }
}
stages {
    stage('Install') {
        steps {
            sh 'pip install --upgrade pip'
        }
    }
}

这将导致以下错误:

The directory '/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
  Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)
Installing collected packages: pip
  Found existing installation: pip 19.0.2
Uninstalling pip-19.0.2:
Could not install packages due to an EnvironmentError: [Errno 13] 
Permission denied: '/usr/local/bin/pip'
Consider using the `--user` option or check the permissions.

我试图使用 --user ,但没有成功。

我用args有点运气 --user 0:0 在docker jenkinsfile声明中,但这会创建根目录和根目录下的文件,用户jenkins在下次运行时无法删除这些目录和文件。

我不想做 pip install 在dockerfile上,因为实际上安装步骤运行的是make文件,而不是我上面使用的简化,我希望在其他上下文中使用。

我也看到了改变 HOME environment var ,这似乎修复了有关父目录不属于当前用户的前两个警告,但没有 Errno 13 部分。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43802
文章 [ 2 ]  |  最新文章 7 年前