docker - Docker .withRun()命令错误

标签 docker jenkins kubectl

我正在尝试将用户的uid更改为0

docker.image('pahud/eks-kubectl-docker').withRun('-u 0:0').inside.{
          withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', 
                        credentialsId: awsCredentialsId,
                        accessKeyVariable: 'AWS_ACCESS_KEY_ID',  
                        secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']])

            {
           sh 'AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} AWS_DEFAULT_REGION=us-west-2  CLUSTER_NAME=oeksctl'

      sh 'aws eks --region us-west-2 update-kubeconfig --name eksctl'

我收到以下错误
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: static org.jenkinsci.plugins.docker.workflow.Docker.withRun() is applicable for argument types: (java.lang.String) values: [-u 0:0]
Possible solutions: with(groovy.lang.Closure), withTool(java.lang.String, groovy.lang.Closure)
    at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1501)
    at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1487)

最佳答案

这应该是这样的

docker.image('pahud/eks-kubectl-docker').inside('-u 0:0'){

代替
docker.image('pahud/eks-kubectl-docker').withRun('-u 0:0').inside{

关于docker - Docker .withRun()命令错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58125447/

相关文章:

jenkins - 在 Jenkins 管道中解析 XML 文件

python - Kubernetes 未记录打印

kubernetes - Kubernetes服务运行正常,但无法从外部访问

docker - 处理 tar 文件时出错(退出状态 1): unexpected EOF when building with docker-compose while data directory exists

docker - apt-add-repository : command not found error in Dockerfile

docker - Docker 公开的端口无法访问

Jenkins 订书机请求失败,没有有效的面包屑

git - 从 jenkins 执行 git describe 命令

Kubernetes 可以 telnet 进入 POD,但不能 curl 网页内容

Docker EXPOSE 使用运行时环境变量