docker invalid reference format error with image python 3.6.8

Viewed 40

I am running a pipeline and getting below error:

$ docker run -t -d -u 113:119 -v /etc/passwd:/etc/passwd ; -v /var/lib/jenkins/.ssh:/var/lib/jenkins/.ssh; -v /var/lib/jenkins/workspace/M-T-Pipeline_develop/induser:/var/lib/jenkins/workspace/M-T-Pipeline_develop/induser -w /var/lib/jenkins/workspace/M-T-Pipeline_develop -v /var/lib/jenkins/workspace/M-T-Pipeline_develop:/var/lib/jenkins/workspace/M-T-Pipeline_develop:rw,z -v /var/lib/jenkins/workspace/M-T-Pipeline_develop@tmp:/var/lib/jenkins/workspace/M-T-Pipeline_develop@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** python:3.6.8 cat
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // gitlabBuilds
Post stage
[Pipeline] updateGitlabCommitStatus
No GitLab connection configured
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] updateGitlabCommitStatus
No GitLab connection configured
[Pipeline] mail
Error when executing failure post condition:
java.lang.NoSuchMethodError: 'jenkins.plugins.mailer.tasks.MimeMessageBuilder jenkins.plugins.mailer.tasks.MimeMessageBuilder.addRecipients(java.lang.String, javax.mail.Message$RecipientType)'
    at org.jenkinsci.plugins.workflow.steps.MailStep$MailStepExecution.buildMimeMessage(MailStep.java:167)
    at org.jenkinsci.plugins.workflow.steps.MailStep$MailStepExecution.run(MailStep.java:142)
    at org.jenkinsci.plugins.workflow.steps.MailStep$MailStepExecution.run(MailStep.java:129)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

[Pipeline] }
[Pipeline] // stage
[Pipeline] }

[Pipeline] // ansiColor
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: Failed to run image 'python:3.6.8'. Error: docker: invalid reference format.
See 'docker run --help'.
    at org.jenkinsci.plugins.docker.workflow.client.DockerClient.run(DockerClient.java:145)
    at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:200)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:322)

Below is the snippet for the stage:

stage("Test - ${ENV}"){
                                        docker.image('python:3.6.8').inside('-v /etc/passwd:/etc/passwd  -v /var/lib/jenkins/.ssh:/var/lib/jenkins/.ssh -v /usr/local/bin:/usr/local/bin'){
                                            sh 'mkdir -p gut'
                                            dir("gut")
                                                    {
                                                        git(url: "git@ssh-gitlab.pvt.com:dpo/d2p/tma/g/cicd_g-validation.git", branch: "master", credentialsId: 'x-personal-ssh-key')
                                                    }
                                            withCredentials([
                                                    usernamePassword(credentialsId: Config.awsKeyForBranch.get(env.BRANCH_NAME, 'AWS_DEV_DB_CREDS'), usernameVariable: 'aws_db_user', passwordVariable: 'aws_db_pwd'),
                                                    usernamePassword(credentialsId: 'DEV_s_CREDS', usernameVariable: 's_user', passwordVariable: 's_pwd'),
                                                    string(credentialsId: "${Config.awsAccountForEnv.get(Config.envForBranch.get(env.BRANCH_NAME))}-aws-s3-t-bucket-name", variable: 's3_t_bucket_name'),
                                                    string(credentialsId: "${Config.awsAccountForEnv.get(Config.envForBranch.get(env.BRANCH_NAME))}-aws-s3-t-access-key", variable: 's3_t_access_key'),
                                                    string(credentialsId: "${Config.awsAccountForEnv.get(Config.envForBranch.get(env.BRANCH_NAME))}-aws-s3-t-secret-key", variable: 's3_t_secret_key'),

                                                    sshUserPrivateKey(credentialsId: Config.sshKeyForBranch.get(env.BRANCH_NAME, "DEV_SSH_KEY"), keyFileVariable: 'keyfile')
                                            ])
                                                    {
                                                        sh "ssh -4 -o StrictHostKeyChecking=no -i $keyfile -M -S ctrl-socket -f -N -L 5432:${Config.dbhost.get(env.BRANCH_NAME, "nonprod.x.us-east-1.rds.amazonaws.com")}:5432 ${Config.jumphostForDB.get(env.BRANCH_NAME, "ubuntu@10.x.x.x")}"
                                                        sh  "cd gut; python3 -m venv .env;. .env/bin/activate; python3 -m pip install -r requirements.txt --no-cache-dir; behave --no-capture -D gdbuser=${aws_db_user} -D gdbpwd=${aws_db_pwd} -D suser=${s_user} -D sdbpwd= ${s_pwd} --tags=@Mtr"
                                                    }
                                        }
                                    }
                                }
                            }

I am using :

docker.image('python:3.6.8').inside('-v /etc/passwd:/etc/passwd  -v /var/lib/jenkins/.ssh:/var/lib/jenkins/.ssh -v /usr/local/bin:/usr/local/bin')

because I need to run the same user as in the host . The user in the host is Jenkins and /etc/passwd I have mapped between host and container because of the same reason.

Can someone please suggest some hints?

0 Answers
Related