I have a systemd unit, that uses the command docker-compose to start and stop a given set of containers. It looks like this:
[Unit]
Description=...
[Service]
WorkingDirectory=/opt/tsc-docker
RemainAfterExit=true
ExecStart=/usr/bin/docker-compose up -d --remove-orphans
ExecStop=/usr/bin/docker-compose down
Type=oneshot
[Install]
WantedBy=multi-user.target
It works mostly as expected. If I start this service, the containers come up and go down if I stop it.
What's missing - and what this question is about - is the ability to restart only some containers.
What I mean is, if I edit the docker-compose.yml and run the docker-compose up -d command, only the affected containers are recreated, instead of all of them.
The current unit configuration however doesn't give me the possibility to run systemctl start TscDocker again and have the affected containers recreated. Since the unit is already running, it just ignores my command. If I set RemainAfterExit=false, then the ExecStop command runs just after ExecStart, which is obviously not desirable.
What I need is the ability to start this service multiple times and have ExecStart run each time without ExecStop being run after each ExecStart.
What are my options, to create a configuration that checks all boxes?