Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Docker-containers: Consider the exit status of docker run in ExecStop #76444
Motivation for this change
If the docker run command exits with a positive exit status we don't need to stop it.
In fact, if we try to stop it, the
I am aware that checking things with a shell script like that seems hacky but the systemd manual states that
I have no idea how I would go about using NixOS tests and a link to the source of a bunch of tests doesn't help. If someone could give me an example for this, that'd teach me a lot. (I did test it manually though.)
This is my first PR, I am pretty sure I missed something else too. Please tell me if I did and what.
It is unset currently for declarative docker containers, which means it has type
You may set it with:
Also, you may use
That's exactly what I was looking for, thank you! I'm still learning how to properly interface with the Nix language, so basic things like these are still not obvious to me.
You could to it that way but having to fiddle with systemd services to get your docker containers to behave the way you want is a bit unclean IMO and actually not at all obvious to someone who doesn't know how
That sounds cleaner, I'll take a look. Thanks!
I tried it out and it does indeed look a bit cleaner but I have a few issues with it:
okay, this sounds reasonable.
What about removing ExecStop entirely? Looking at https://docs.docker.com/engine/reference/commandline/stop/:
But this is almost systemd behavior when no ExecStop present (https://www.freedesktop.org/software/systemd/man/systemd.service.html):
The last bit (kill only main process instead of all subprocesses) can be achieved with KillMode=mixed (https://www.freedesktop.org/software/systemd/man/systemd.kill.html#KillMode=)
Yeah, I also thought about that and assumed they were added for good reason.
I the author didn't include a comment on these parameters in their commit message or PR unfortunately but they do mention that reload isn't implemented because docker containers might not respond well to some kill signals (https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/docker-containers.nix#L192), so maybe
I didn't know about
If I recall correctly, the redundant