Do we have docker group on Mac?

2019-06-21 03:35发布

I have installed docker on Mac and everything is running fine. I am using a Jenkins docker image and running it. While using Jenkins as a CI server and to build further images by running docker commands through it, I came to know that we have to bind mount /var/run/docker.sock while running the Jenkins images so it can access the docker daemon.

I did that and installed docker CLI inside Jenkins’s container but when running “docker ps” or any other docker command it is throwing the below error:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.28/containers/json: dial unix /var/run/docker.sock: connect: permission denied

When I connect to container as a root user, it works fine. But switching to the ‘jenkins’ user throws the above error. I have already added ‘jenkins’ user to sudo list but does not help.

I found few articles suggesting to add ‘jenkins’ user to ‘docker’ group but to my surprise I do not find any docker group on Mac or inside container.

Any help is much appreciated. Thanks

标签: macos docker
2条回答
地球回转人心会变
2楼-- · 2019-06-21 04:12

No, but this works:

  • Add the user (e.g. jenkins) to the staff-group: sudo dseditgroup -o edit -a jenkins -t user staff
  • Allow group to sudo, in sudo visudo add: %staff ALL = (ALL) ALL
查看更多
成全新的幸福
3楼-- · 2019-06-21 04:15

I got this issue today. Here is the cause and fix:

I've started docker for mac as user A and try to run docker commands as user B.

Fix:
Stopped docker for mac as user A and started as user B.

查看更多
登录 后发表回答