Skip to main content
0 reactions

How to Enable /var/run/docker.sock in Docker Desktop for Mac

The Advanced section of Docker Desktop Settings on a Mac, with the switch Allow the default Docker socket to be used (requires password) turned on and marked Modified, and its description: Creates /var/run/docker.sock which some third-party clients may use to communicate with Docker Desktop.
Settings › Advanced in Docker Desktop, with the default Docker socket switched on.

Some tools look for Docker at /var/run/docker.sock, its standard address on macOS and Linux. Docker Desktop for Mac keeps its own socket in your home folder, at ~/.docker/run/docker.sock, and creates /var/run/docker.sock only when one setting is on.

This guide turns that setting on, in one place in Docker Desktop’s settings. It’s how the OpenTofu Tutorial’s Docker parts reach Docker on a Mac.

Prerequisites

Step 1: Open the Advanced Settings

In Docker Desktop, click the gear icon (Settings) at the top right. Then click Advanced in the list of settings sections.

Step 2: Turn On the Default Docker Socket

Switch on Allow the default Docker socket to be used (requires password). Docker Desktop marks it Modified until you apply it:

The Advanced section of Docker Desktop Settings on a Mac, with the switch Allow the default Docker socket to be used (requires password) turned on and marked Modified, and its description: Creates /var/run/docker.sock which some third-party clients may use to communicate with Docker Desktop.
Settings › Advanced in Docker Desktop, with the default Docker socket switched on.

Step 3: Apply the Change

Click Apply at the bottom of the window, then type your Mac password when macOS asks:

The bar at the bottom of Docker Desktop Settings saying 1 unsaved change, with the buttons Discard and Apply.
Click Apply to save the change.

Docker Desktop creates /var/run/docker.sock as a link to its own socket. Tools that use Docker’s standard address can now reach Docker Desktop, without any setting of their own.

Turn It Off Again

Switch the same setting off and click Apply. Docker Desktop’s own tools keep working, because they use the socket in your home folder.

FAQ

Why does Docker Desktop ask for my password?

/var/run is a system folder that belongs to the administrator account, so adding anything to it needs an administrator’s password.

Do I need this on Windows or Linux?

No. This setting is for Docker Desktop on a Mac. On Linux, Docker Engine creates /var/run/docker.sock itself, and Windows uses a named pipe instead.

Conclusion

One setting in Docker Desktop gives your Mac the standard Docker socket, so tools such as OpenTofu®’s Docker provider find Docker without extra configuration.

Additional Resources

Docker and Docker Desktop are trademarks of Docker, Inc. Other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by Docker, Inc.

0 comments