How to use docker command in jenkins shell

Expected behavior

Expected execute docker command in jenkins shell

Actual behavior

When I execute /var/local/bin/docker, it tells me that permission denied.


  • the output of:
    • /usr/local/bin/docker: Permission denied

Steps to reproduce the behavior

  1. Install Docker for Mac
  2. install jenkins for Mac
  3. start a jenkins project
  4. add execute shell script /usr/local/bin/docker images

I don’t think that is going to work since /usr/local/bin/docker is just a symlink to Library/Group Containers/ Permissions ~/Library are locked to the user and you’d have to open them to other users/groups (not recommended) in order to achieve what you are looking to do. Perhaps a VM with Jenkins and Docker on a Linux guest would be a better solution (unless you have a need to run Jenkins on Mac, perhaps for using xcode tools to build iOS/macOS apps)…

Actually I just realized /usr/local/bin/docker is a symlink to a symlink which ultimately resolves to /Applications/

You may want to try using the full path in your Jenkins test:
/Applications/ images

Thank you for your patient answer.

The path of /Applications/ can be executed, but it tells me that Cannot connect to the Docker daemon. Is the docker daemon running on this host? But the docker for mac is running.

It must have to do with how the docker command is set to communicate with the almost-transparent xhyve VM. I’m stumped. However, regarding my original suggestion, does your use case require Jenkins to build anything iOS/macOS specific?

Thank you . Yes, I’m must use jenkins for iOS project build

I have this same problem. Has anyone found a solution?

best to use a docker client inside a container and just mount the docker socket it works without any issues

here is docker image that has a docker client inside

so if you run it with
docker run -it -v /var/run/docker.sock,target=/var/run/docker.sock docker bash

and inside any command will be run against the main docker daemon.

Also you might useful this step by step tutorial I did for Jenkins and docker pipeline