What is Docker Socket?
Docker socket file is located at /var/run/docker.sock It is used to communicate with the main docker daemon (process) by default. It is the entry point for a Docker API. This socket is used by Docker CLI by default to execute docker commands. Let me show you how to change the location of the docker sock file.
Stop Docker
Firstly, if the docker service is running on your system, stop it. To confirm it has stopped, run the status command.
Edit docker.conf and docker.socket
The following, I am changing the path from /var/run/docker.sock to /home/geekflare/docker.sock
Edit the docker.conf file inside /etc/init/ directory with the new location. You just need to edit one line with DOCKER_SOCKET path.
Edit the docker.socket file located at /lib/systemd/system/ with the updated docker.sock file location.
Run the below command to update the changes (location of docker sock file).
Start Docker
Let’s start the docker service, and check the status if it got started. You will see at the end of the status log printed on the terminal will give the updated path of docker.sock file. Run the ls command at the path of docker.sock file, just to confirm that this file got created when you started the docker service. You have successfully updated the location of docker sock file. If you are looking to learn Docker but busy, then check out this crash course.