Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker: command not found ( mac mini ) only happens in jenkins shell step but work from command prompt

I'm facing this weird problem , struggling to solve since almost couple of days.

Working: On mac mini command prompt , I switch to jenkins user and can run docker command without any problem.

Not Working: but when I run a jenkins job , inside shell command step docker is not recognized.

I'm getting error

docker: command not found

docker --version

But mentioning explicit path of docker , does work

/Users/buildserver/Library/Group\ Containers/group.com.docker/bin/docker --version

Question : Why docker command can't look into correct path ?

Permissions

lrwxr-xr-x 1 buildserver staff 71 Oct 14 10:44 docker -> /Users/buildserver/Library/Group Containers/group.com.docker/bin/docker

jenkins uses is part of staff group.

Thanks in advance.

Regards, Vikram

like image 217
vikramvi Avatar asked Oct 14 '16 12:10

vikramvi


1 Answers

For others (Late but worthy), I installed Jenkins via Brew, so I add Docker's path to the file below: /usr/local/Cellar/jenkins-lts/2.176.3/homebrew.mxcl.jenkins-lts.plist (Whole file looks like below)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>homebrew.mxcl.jenkins-lts</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/libexec/java_home</string>
      <string>-v</string>
      <string>1.8</string>
      <string>--exec</string>
      <string>java</string>
      <string>-Dmail.smtp.starttls.enable=true</string>
      <string>-jar</string>
      <string>/usr/local/opt/jenkins-lts/libexec/jenkins.war</string>
      <string>--httpListenAddress=127.0.0.1</string>
      <string>--httpPort=8080</string>
    </array>
    <key>RunAtLoad</key>
    <true />
    <key>EnvironmentVariables</key>
    <dict>
      <key>PATH</key>
      <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Docker.app/Contents/Resources/bin/:/Users/Kh0a/Library/Group\ Containers/group.com.docker/Applications/Docker.app/Contents/Resources/bin</string>
    </dict>
  </dict>
</plist>

Then restart Jenkins' service:

brew services restart jenkins-lts

More question

like image 196
Khoa Avatar answered Oct 21 '22 09:10

Khoa