What can I do with this? cmd-socket is a very slim and ultra simple socket http server that will execute commands on the host systems it runs on. Its purpose is to give other containers the ability to execute commands on other systems by simply mounting the socket. You can for instance run a scheduled command in another container without having to open access to the Docker socket. The compose.yaml of the 11notes/postgres image has a great example for this use.
- -s - path to socket file, by default /run/cmd/cmd.sock
The http server will parse any json object in this format.
{
"bin":"df",
"arguments":["-h"],
"environment":{}
}- bin - The name of the binary to be executed by the socket, required
- arguments - An array ([]string) with the parameters passed to the binary, optional
- environment - An object ([]string) with the environment passed to the binary, optional
curl --unix-socket /run/cmd/cmd.sock http:/cmd -H 'Content-Type: application/json' -d '{"bin":"df", "arguments":["-h"]}'
curl --unix-socket /run/cmd/cmd.sock http:/cmd -H 'Content-Type: application/json' -d '{"bin":"env", "environment":{"FOO":"bar"}}'