After searching for a bit, I found a way to send commands to a Resonite headless within Docker programmatically without having to run docker compose attach <container>
and having to manually detach.
You will need the software socat
installed on the host machine, given most of my machines are running Debian, this can be done via apt install socat
.
Now, you can use:
echo 'worlds' | socat EXEC:"docker attach $(docker compose ps -q reso-headless)",pty STDIN
In this command, replace:
worlds
by the command you wantreso-headless
by the defined name of your headless container
Alternatively, you can just specify the container name directly instead of doing $(docker compose ps -q reso-headless)
.
Addendum:
For this to work, you will have to make sure your container is defined with:
tty: true stdin_open: true
in the Compose file.