I can give you ideas, but I don’t use Synology so I can’t really help you with that. I also have to note for future readers that I don’t normally recommend any of the below ideas. The best would be copying everything out from the container and creating a new image that contains everything. You will need to do that sometime in the future anyway, otherwise if anything happens with the container and can’t start it or somehow it gets deleted, you will lose everything that was in the container. Even if it was a virtual machine, you would need backups and possibly a mounted network filesystem independent of the VM. .
First idea: docker exec
If you had Docker CE on Linux, you could create a szkript which starts the container and use
docker exec to start additional processes:
docker start mycontainer
docker exec mycontainer crond
Again, this is just an idea. I don’t know the required parameters of crond.
- I don’t know how you could run docker commands in a script on Synology
- Even if you can run the script, when you stop the container only the original process would get the stop signal and everything else would be just killed which could lead to data loss or any kind of inconsistency…
Second idea: overwriting the original start script
Assuming the original image had CMD instruction like this:
You could overwrite
start.sh. That way you could also install supervisor and let it handle all processes. The start script would like like this:
exec supervisord --nodaemon -c "/etc/supervisor/supervisord.conf"
This way thanks to the exec command, supervisor becomes the first process and can handle stop signals so the processes can finish their job before stopping.
Third idea: overwrite a binary
Let’s say there was no start script just a binary like:
Then you could rename
application-orig and create a shel script without extension with the same content I recommended in my second idea. Of course you don’t have to use supervisor, but if you don’t use a process manager, you will still have problem with properly stopping the container.
Fourth idea: docker commit
You can save the current container as an image using
docker commit mycontainer myimage:2023-08-01
Then create a new Dockerfile and use that as a base image:
CMD ["supervisord", "--nodaemon", "-c", "/etc/supervisor/supervisord.conf"]
I hope you can find something helpful in the above ideas.