# Enable docker commands run without sudo

**URL:** <https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671>\
**Category:** Docker Desktop\
**Tags:** macos\
**Created:** [April 19, 2023, 8:39am UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671 "2023-04-19T08:39:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![deem0ne](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@deem0ne](https://forums.docker.com/u/deem0ne)\
**Post date:** [April 19, 2023, 8:39am UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/1 "2023-04-19T08:39:39Z")

</div>

How can I enable accessing Docker through terminal in Mac without always typing ‘sudo’?  
If I type `docker` or `docker-compose`, `I'm getting 'ZSH command not found`, but when I’m adding `sudo` it works as intended.

I tried to do the tricks found through the internet, but no one actually works:  
`sudo dscl . delete /Groups/docker GroupMembership Myusername`  
`sudo chmod a+x /usr/local/bin/docker-compose`  
All types of other advices are intended for Linux, not Mac.

The permissions seems to be okay:

```auto
lrwxr-xr-x@ 1 root wheel 54 Apr 18 19:19 docker -> /Applications/Docker.app/Contents/Resources/bin/docker
lrwxr-xr-x@ 1 root wheel 62 Apr 18 19:19 docker-compose -> /Applications/Docker.app/Contents/Resources/bin/docker-compose

```

Strangely, when I watched many videos of using Docker commands in Terminal, all users which streamed their videos didn’t used sudo or wasn’t typing this commands under the **root** user.

Docker latest 4.18  
MacOS 13.2

Thank you.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [April 21, 2023, 7:17pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/2 "2023-04-21T19:17:21Z")

</div>

Since the error message is “command not found” and not “permission denied”, I think there is nothing wrong with permissions and group membership. My guess is that `/usr/local/bin` is not in PATH variable in the ZSH shell. It could be for example because you tried to add a new fodler to PATH and acidentally overwrote it instead of appending or prepending a new value.

You can try the following ways to confirm it:

1. The below command should show you if the necessary folder is added to the PATH.

2. Start a bash shell from zsh and try docker from there:

If `/usr/local/bin` is indeed missing from ZSH, you need to add it back or find out what and why removed it. Check your `$HOME/.zshrc` file for example.

---

<div class="post-metadata">

**Author:** ![deem0ne](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@deem0ne](https://forums.docker.com/u/deem0ne)\
**Post date:** [April 23, 2023, 10:26am UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/3 "2023-04-23T10:26:43Z")

</div>

Hi, Rimelek!  
Thank you for your suggestions. Getting back with feedback of running commands, you mentioned above.

> 1. The below command should show you if the necessary folder is added to the PATH.  
> echo $PATH | tr ‘:’ ‘\n’ | grep ‘/usr/local/bin’

Runned this under my user acc without sudo:

```auto
Deemone:~ Deemone$ echo $PATH | tr ':' '\n' | grep '/usr/local/bin'
/usr/local/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin

```

Running this command under su has brought me the same:

```auto
sh-3.2# echo $PATH | tr ':' '\n' | grep '/usr/local/bin'
/usr/local/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin

```

So, as I take, the necessary folder is in the PATH and all is okay.

> 1. Start a bash shell from zsh and try docker from there:  
> bash -l

Here is an output. Switching zsh to bash hasn’t helped unfortunately. I made sure below that a switch of zsh → bash was done.

```auto
Deemone@Deemone ~ % echo $0       
-zsh
Deemone@Deemone ~ % bash -l
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Deemone:~ Deemone$ echo $0
bash
Deemone:~ Deemone$ docker info
bash: docker: command not found
Deemone:~ Deemone$ 

```

---

<div class="post-metadata">

**Author:** ![alishah730](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/alishah730/32/40394_2.png) [@alishah730](https://forums.docker.com/u/alishah730)\
**Post date:** [April 23, 2023, 11:26am UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/4 "2023-04-23T11:26:12Z")

</div>

This works properly on my Mac without any sudo.

 ![image](https://global.discourse-cdn.com/docker/original/3X/3/6/362f7c3572a8ad3fa3e4ecf4da1c1f48b719dfab.jpeg)

I would suggest re-install docker desktop with proper permission, it usually asks for credentials when you do drag and drop.

if you have installed docker using **cli command and sudo** then you have to give permission to your user to run docker.

---

<div class="post-metadata">

**Author:** ![deem0ne](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@deem0ne](https://forums.docker.com/u/deem0ne)\
**Post date:** [April 23, 2023, 2:00pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/5 "2023-04-23T14:00:21Z")

</div>

> [@alishah730](#):
>
> I would suggest re-install docker desktop with proper permission, it usually asks for credentials when you do drag and drop.

Thank you for reporting.  
I did reinstalling for several times after preceeding uninstall procedure, with no success.  
I installed it straight like you showed it, by dragging and dropping to my applications folder and answered ‘yes’ when its asked for permissions.

---

<div class="post-metadata">

**Author:** ![alishah730](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/alishah730/32/40394_2.png) [@alishah730](https://forums.docker.com/u/alishah730)\
**Post date:** [April 23, 2023, 4:53pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/6 "2023-04-23T16:53:21Z")

</div>

> [@deem0ne](#):
>
> `/Applications/Docker.app/Contents/Resources/bin/`

Hello @deem0ne  
below is my permission level for those binaries

 ![image](https://global.discourse-cdn.com/docker/original/3X/9/0/90365b7b47f43c8d664d71054a4b0fe92f3fe406.png)

and I’m already admin user

 ![image](https://global.discourse-cdn.com/docker/original/3X/e/3/e35187fe323c6f84ed648599e4f992c9bd4aac2c.png)

please check your user permission

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [April 23, 2023, 5:04pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/7 "2023-04-23T17:04:12Z")

</div>

> [@deem0ne](#):
>
> Runned this under my user acc without sudo:

That is strange. I didn’t expect that. Please try this command too:

```auto
which docker

```

and also this to show the permissions of docker related binaries

```auto
ls -la /usr/local/bin/docker*

```

and the same in the Docker app folder:

```auto
ls -la /Applications/Docker.app/Contents/Resources/bin/

```

Note: While I was typing my message @alishah730 asked for whosing the permissions too, but I will keep it in my message too 🙂

The strange thing is that if it is a permission issue, the message should be different and I tried to change thebroke the permissions and got different message.

---

<div class="post-metadata">

**Author:** ![deem0ne](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@deem0ne](https://forums.docker.com/u/deem0ne)\
**Post date:** [April 23, 2023, 6:49pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/8 "2023-04-23T18:49:51Z")

</div>

> [@rimelek](#):
>
> `ls -la /Applications/Docker.app/Contents/Resources/bin/`

Rimelek, here is an output. I did under my user acc with admins rights without doing su/sudo:

```auto
Deemone@Deemone ~ % which docker
docker not found
Deemone@Deemone ~ % ls -la /usr/local/bin/docker*
zsh: no matches found: /usr/local/bin/docker*
Deemone@Deemone ~ % ls -la /Applications/Docker.app/Contents/Resources/bin/
total 538688
drwxr-xr-x@ 13 Deemone admin 416 Apr 5 11:21 .
drwxr-xr-x@ 16 Deemone admin 512 Apr 5 11:21 ..
-rwxr-xr-x@ 1 Deemone admin 45914512 Apr 5 11:21 com.docker.cli
-rwxr-xr-x@ 1 Deemone admin 23461472 Apr 5 11:21 com.docker.vpnkit
-rwxr-xr-x@ 1 Deemone admin 65666176 Apr 5 11:21 docker
-rwxr-xr-x@ 1 Deemone admin 6802320 Apr 5 11:21 docker-compose
drwxr-xr-x@ 75 Deemone admin 2400 Apr 5 11:21 docker-compose-v1
-rwxr-xr-x@ 1 Deemone admin 9788688 Apr 5 11:21 docker-credential-desktop
-rwxr-xr-x@ 1 Deemone admin 8891712 Apr 5 11:21 docker-credential-ecr-login
-rwxr-xr-x@ 1 Deemone admin 1898016 Apr 5 11:21 docker-credential-osxkeychain
-rwxr-xr-x@ 1 Deemone admin 49481488 Apr 5 11:21 docker-index
-rwxr-xr-x@ 1 Deemone admin 14185520 Apr 5 11:21 hub-tool
-rwxr-xr-x@ 1 Deemone admin 49704688 Apr 5 11:21 kubectl

```

---

<div class="post-metadata">

**Author:** ![deem0ne](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@deem0ne](https://forums.docker.com/u/deem0ne)\
**Post date:** [April 23, 2023, 6:53pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/9 "2023-04-23T18:53:56Z")

</div>

> [@alishah730](#):
>
> Hello @deem0ne  
> below is my permission level for those binaries

Hi, [alishah730](https://forums.docker.com/u/alishah730)!  
Here it is. The whole output of this command is above:

```auto
-rwxr-xr-x@ 1 Deemone admin 23461472 Apr 5 11:21 com.docker.vpnkit
-rwxr-xr-x@ 1 Deemone admin 65666176 Apr 5 11:21 docker
-rwxr-xr-x@ 1 Deemone admin 6802320 Apr 5 11:21 docker-compose
drwxr-xr-x@ 75 Deemone admin 2400 Apr 5 11:21 docker-compose-v1

```

And my permissions is admin for sure:  
Under this acc I was able to activate Root user and make other system-critical changes, so its 100% admin.  
 ![Screenshot 2023-04-23 at 22.50.43](https://global.discourse-cdn.com/docker/original/3X/4/7/47a5049bacba7f076943ec5156c1bf3fe1d646a2.png)

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [April 23, 2023, 7:11pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/10 "2023-04-23T19:11:28Z")

</div>

In your first post you showed docker and docker-compose binary linked to binaries (I missed it first) in the Docker App so you shouldn’t have got an empty result after running

```auto
ls -la /usr/local/bin/docker*

```

What if you try this?

```auto
ls -la /usr/local/bin | grep docker

```

(I just don’t want to you to list all the files in that folder, because there could be commands that you don’t wan to share)

I still don’t understand what is happening but if something happened during the installation of Docker Desktop, you could try to completely remove every component which I ams ure you tried, but I know from experience it is not always easy to find all the remained compontents. I have made a video about it, although it was for an odler version but I mention in the video too that I shared only ideas not a perfect solution for every case. You can still try it: [Uninstalling Docker Desktop properly on macOS - YouTube](https://www.youtube.com/watch?v=maQJSnRdy10)

It already helped some people

---

<div class="post-metadata">

**Author:** ![deem0ne](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@deem0ne](https://forums.docker.com/u/deem0ne)\
**Post date:** [April 23, 2023, 7:32pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/11 "2023-04-23T19:32:36Z")

</div>

> [@rimelek](#):
>
> `ls -la /usr/local/bin | grep docker`

Did it even without grep. Permission denied.

```auto
Deemone@Deemone ~ % ls -la /usr/local/bin              
total 0
ls: /usr/local/bin: Permission denied

```

Under SU its all works. So, as I take, there is something wring with my system.  
I runned a clear copy of MacOS in Virtual machine it it successfully does `ls -la /usr/local/bin` without su.

> [@rimelek](#):
>
> You can still try it: [Uninstalling Docker Desktop properly on macOS - YouTube](https://www.youtube.com/watch?v=maQJSnRdy10)

Yes, I tried to remove Docker completely with searching for its files + system files included + searching in stackoverflow for where it can leave its traces. I will investigate into your video, thanks.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [April 23, 2023, 8:10pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/12 "2023-04-23T20:10:47Z")

</div>

> [@deem0ne](#):
>
> Did it even without grep. Permission denied.

Now that is a problem. It looks like you don’t have permission to see files in the folder so the fact that you could execute files inside doesn’t help.

Please, try this now:

```auto
ls -ld /usr/local/bin

```

It should show this:

```auto
drwxr-xr-x 30 root wheel 960 Mar 13 01:06 /usr/local/bin

```

The fodler has to be “executable” by anyone otherwise you can’t list files inside. If it is the case, then giving back the permision to the fodler could solve the issue (let’s hope it does)

```auto
chmod +x /usr/local/bin

```

---

<div class="post-metadata">

**Author:** ![deem0ne](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@deem0ne](https://forums.docker.com/u/deem0ne)\
**Post date:** [April 23, 2023, 8:17pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/13 "2023-04-23T20:17:05Z")

</div>

> [@rimelek](#):
>
> `drwxr-xr-x 30 root wheel 960 Mar 13 01:06 /usr/local/bin`

I got following:

```auto
Deemone@Deemone ~ % ls -ld /usr/local/bin
drwx------ 25 root wheel 800 Apr 19 14:15 /usr/local/bin

```

Do I run `chmod +x /usr/local/bin`, right?

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [April 23, 2023, 8:18pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/14 "2023-04-23T20:18:09Z")

</div>

Yes, you need to run chmod as root, but also add read permission

---

<div class="post-metadata">

**Author:** ![deem0ne](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@deem0ne](https://forums.docker.com/u/deem0ne)\
**Post date:** [April 23, 2023, 8:27pm UTC](https://forums.docker.com/t/enable-docker-commands-run-without-sudo/135671/15 "2023-04-23T20:27:57Z")

</div>

Did `chmod +xr /usr/local/bin` and the problem finally resolved!

```auto
Deemone@Deemone ~ % ls -ld /usr/local/bin  
drwxr-xr-x 25 root wheel 800 Apr 19 14:15 /usr/local/bin

```

After reboot Docker’s and Kubernate’s commands are accessible and even Kubernete’s context menu works like a charm. So this is resolved too now: [https://forums.docker.com/t/unable-to-run-embedded-kubernetes-on-docker-desktop-mac/135652](https://forums.docker.com/t/unable-to-run-embedded-kubernetes-on-docker-desktop-mac/135652)  
You are Godlike! Thank you so much!  
The issue is resolved.
