How to run Docker daemon on a different port in Mac.

Shashank Srivastava
1 min readJan 15, 2020

--

Expose your Docker’s daemon to a different port in just 2 steps.

If you need to run Docker daemon on a different port in your Mac, just follow the below steps.

  1. Execute the below command. Replace 2375 with a port of your choice.
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:2375:2375 bobrik/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock

2. Export the DOCKER_HOST environment variable.

Now add the below line to your bash_profile file to export this variable.

export DOCKER_HOST=tcp://localhost:2375

Of course, you will need to source the bash_profile file to set the variable.

Now you can see that the Docker daemon is running on port 2375.

root@shashank-mbp /U/a/D/quote-randomizer# lsof -i -n -P  | grep 2375
com.docke 1656 admin 17u IPv4 0x6ef77b4e1eda469 0t0 TCP 127.0.0.1:2375 (LISTEN)

You may also like my other post on Docker…

--

--

Shashank Srivastava
Shashank Srivastava

Written by Shashank Srivastava

DevSecOps Architect @Virtualness. Music/Book/Photography/Fitness lover & Blogger.

Responses (1)