Thursday, March 15, 2018

/var/run/docker.sock

ls -ltra /var/run/docker.sock
srw-rw----. 1 root docker 0 Feb 12 15:49 /var/run/docker.sock



https://www.gnu.org/software/coreutils/manual/html_node/What-information-is-listed.html#What-information-is-listed "s" stands for Unix socket

Communication between a Docker container and Docker daemon can happen via this socket (see Portainer and "docker in docker"


https://medium.com/lucjuggery/about-var-run-docker-sock-3bfd276e12fd
excellent explanation of the /var/run/docker.sock


This REST call via /var/run/docker.sock will create a cointainer:

docker pull nginx:latest
curl -H "Content-Type: application/json" -X POST --unix-socket /var/run/docker.sock -d '{"Image":"nginx"}' http://localhost/containers/create

amazing!


This PRICELESS command, run on the host, can trace all the events handled by the docker daemon:

curl --unix-socket /var/run/docker.sock http://localhost/events



No comments: