April 29, 2017

Relevant Linux Features: UNIX Domain Socket

UNIX Domain Socket


UNIX domain socket, also known as IPC (inter-process communication) socket is a data communications endpoint for exchanging data between processes executing on the same host.

Unlike a regular shell pipeline, or pipe (|), which allows communication between command and in only one direction, the UNIX domain socket is bi-directional, i.e. it enables a two-way communications channel.

Similar concepts:
  • TCP Sockets
    • enables bi-directional communication channel between two endpoints over the Internet
  • Pipes
    • one-way communication channel between commands on the local host
    • a sequence of processes chained together by their standard streams, where the standard output (stdout) of one process is fed to the next process through its standard input (stdin)
  • FIFO
    • First In First Out
    • Also known as a named pipe
    • unidirectional communication channel between two processes on the local host
    • Can be accessed by two processes, one to write data, the other to read data
    • Can be created and named by commands: mkfifo or mknod

UNIX domain socket allows processes on the same host can communicate.
All communication occurs entirely within the operating system kernel
Unix domain sockets use the file system as their address name space.
A UNIX domain socket is known by a pathname where the client and server agree on the pathname used for the communication

The /var/run/docker.sock is an implementation of the UNIX domain socket, used by Docker. The Docker daemon listens on it by default and it enables communication between the Docker daemon and containers.


References:

No comments:

Post a Comment