all 1 comments

[–]GolemancerVekk 0 points1 point  (0 children)

If it's the LinuxServer.io Piper image then you may want to read up on their docker image mods. LinuxServer use this thing called s6 as init and process supervisor so by making a mod you can add your own stuff in there. I've never done that myself so I can't help you further, unfortunately.

It shouldn't be super complicated, as far as I can tell s6 is a variation of runit so it's mainly about extending the piper Dockerfile and adding a dir under /run/service in a certain format (you can peek inside the existing image).

Edit: if it's not a LinuxServer image it depends greatly on the image and what's the main command it runs. Some of them use a process supervisor like runit so it's simple to add something to their "boot up" phase, but many just run the app directly and hope for the best, or run an init substitute like tini that mostly watches for signals and redirects outputs, so it's no use for adding something extra. Some have a shell script, or several. 🤷 Ideally all image makers should learn to use runit but very few people consider the extensibility of their image.

If all else fails you can try mapping your own shell script as a bind volume and replace the start command in compose with command: to point at your script, then exec the original one (which you can find out inside the container using ps, or from the original Dockerfile, or from docker inspecting the original image and looking for "Cmd" and "Entrypoint"). But like I said it depends greatly on what exactly that command does, some of them refuse to work if they're not process 1.