Unix Socket
Unix sockets provide inter-process communication on the same machine, commonly used by Docker, databases, and system services.
Overview
Common Socket Paths
| Service | Socket Path |
|---|---|
| Docker | /var/run/docker.sock |
| containerd | /run/containerd/containerd.sock |
| MySQL | /var/run/mysqld/mysqld.sock |
| PostgreSQL | /var/run/postgresql/.s.PGSQL.5432 |
| PHP-FPM | /var/run/php/php-fpm.sock |
Making a Request
- Select Unix Socket from the protocol dropdown
- Enter the Socket Path:
/var/run/docker.sock - Select the HTTP Method: GET, POST, etc.
- Enter the Path:
/v1.43/containers/json - Click Run
Request Configuration
Socket Path
The absolute path to the Unix socket file:
/var/run/docker.sock
Method
Standard HTTP methods are supported:
- GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Path
The HTTP path to request:
/v1.43/containers/json?all=true
Headers
Add custom headers as needed:
| Header | Value |
|---|---|
Content-Type | application/json |
Body
For POST/PUT/PATCH requests, include a JSON body.
Docker API Examples
List Containers
Socket: /var/run/docker.sock
Method: GET
Path: /v1.43/containers/json
Response:
[
{
"Id": "abc123...",
"Names": ["/my-container"],
"Image": "nginx:latest",
"State": "running"
}
]
Get Container Details
Socket: /var/run/docker.sock
Method: GET
Path: /v1.43/containers/{{CONTAINER_ID}}/json
Create Container
Socket: /var/run/docker.sock
Method: POST
Path: /v1.43/containers/create?name=my-nginx
Body:
{
"Image": "nginx:latest",
"ExposedPorts": {
"80/tcp": {}
},
"HostConfig": {
"PortBindings": {
"80/tcp": [{"HostPort": "8080"}]
}
}
}
Start Container
Socket: /var/run/docker.sock
Method: POST
Path: /v1.43/containers/{{CONTAINER_ID}}/start
Stop Container
Socket: /var/run/docker.sock
Method: POST
Path: /v1.43/containers/{{CONTAINER_ID}}/stop
List Images
Socket: /var/run/docker.sock
Method: GET
Path: /v1.43/images/json
Playground Example
The playground includes a Unix socket server (macOS/Linux only):
Socket: /tmp/istek-playground.sock
Method: GET
Path: /api/products
Permissions
Unix sockets require appropriate file permissions. Common issues:
Permission Denied
# Add user to docker group
sudo usermod -aG docker $USER
# Or adjust socket permissions
sudo chmod 666 /var/run/docker.sock
Socket Not Found
- Verify the service is running
- Check the socket path is correct
- Ensure the socket file exists
Platform Support
| Platform | Support |
|---|---|
| macOS | Full support |
| Linux | Full support |
| Windows | Not supported |
note
Unix sockets are not available on Windows. Use TCP connections or named pipes instead.
Tips
Docker API Version
Always specify the API version in the path (e.g., /v1.43/) to ensure compatibility.
Variables
Use variables for container IDs and other dynamic values:
Path: /v1.43/containers/{{CONTAINER_ID}}/logs