My Ubuntu server primarily runs services in docker containers, all configured via docker-compose.
Each time I make a modification to the docker compose configuration file, I then need to run a command to update the docker containers.
docker-compose -f /octoprint/docker-compose.yml up -d --remove-orphans
Typing this isn’t too much pain, but regardless I still wanted to streamline this due to the frequency I run the command.
I wrote the below into a batch file that can be run from any device on my LAN:
@echo off
set host=MYIP
set username=MYUSERNAME
set password=MYPASSWORD
set command=docker-compose -f /octoprint/docker-compose.yml up -d --remove-orphans
echo Running command on %host% as %username%...
echo y | plink.exe %username%@%host% -pw %password% "%command%"
echo Done.
pause
This file upon being double clicked will open a terminal, connect to the host via SSH, authenticate with my given credentials and run the command.
It will also remain open such that I can review the output of the commands and spot any issue with any container initializations.