[JIRA] (JENKINS-58657) sh not working inside docker container

5 views
Skip to first unread message

szhyhalo@gmail.com (JIRA)

unread,
Jul 25, 2019, 5:46:02 AM7/25/19
to jenkinsc...@googlegroups.com
Oleksandr Zhyhalo created an issue
 
Jenkins / Bug JENKINS-58657
sh not working inside docker container
Issue Type: Bug Bug
Assignee: Carlos Sanchez
Components: docker
Created: 2019-07-25 09:45
Priority: Minor Minor
Reporter: Oleksandr Zhyhalo

sh command not working wile specifying user to run inside contrainer.
Example:

docker.image('node:latest').inside('--user node') {
stage('Pull repository') {    
    sh 'whoami'
}    

In this case checkout and other jenkins functions is working, but not any of sh

Process is pending for 5 minutes and then return:

process apparently never started in /var/lib/jenkins/workspace/contrail-ui/contrail-ui-builder@2@tmp/durable-ae2b4ade (running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)

Error appears to be with any container.

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

jenkins-io@ewus.de (JIRA)

unread,
Aug 1, 2019, 11:34:02 AM8/1/19
to jenkinsc...@googlegroups.com
Erik Wegner commented on Bug JENKINS-58657
 
Re: sh not working inside docker container

This seems somewhat related to https://github.com/jenkinsci/docker/issues/626#issuecomment-508444712

In my scenario, there are two containers on a kubernetes pod, one is the jnlp-slave.
The directory /home/jenkins/agent/workspace/<jobname>@tmp/durable-831063bb exists and is used for steps running inside the jnlp-container.
The sh-step running inside the other container tries to access the wrong directory and outputs these messages:

sh: 1: cannot create /home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt: Permission denied
sh: 1: cannot create /home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-result.txt.tmp: Permission denied
touch: cannot touch '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt': Permission denied
mv: cannot stat '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-result.txt.tmp': No such file or directory
touch: cannot touch '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt': Permission denied

jenkins-io@ewus.de (JIRA)

unread,
Aug 2, 2019, 3:58:03 AM8/2/19
to jenkinsc...@googlegroups.com

Update: the directory was created, but for the wrong user. The directory was created by/for user id 1000, but my second container was using id 10000. The directory's permissions are set to 0x755.

Updating the Dockerfile helped to run the script again.

demndell@gmail.com (JIRA)

unread,
Aug 26, 2019, 5:48:02 AM8/26/19
to jenkinsc...@googlegroups.com

I have run into this issue too. In my case the problem was an empty env variable.

I have made a PR https://github.com/jenkinsci/docker-workflow-plugin/pull/185

Reply all
Reply to author
Forward
0 new messages