-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
nixos/docker-containers: daemonize docker run and handle restarts by docker #77479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@GrahamcOfBorg test docker-containers |
2e654a7
to
fa07148
Compare
@GrahamcOfBorg test docker-containers |
@@ -204,8 +209,8 @@ let | |||
|
|||
serviceConfig = { | |||
ExecStart = concatStringsSep " \\\n " ([ | |||
"${pkgs.docker}/bin/docker run" | |||
"--rm" | |||
"${pkgs.docker}/bin/docker run -d" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about daemonizing the container. One of the nice things about keeping it in the foreground is that systemd can know when the container crashes and report it in systemctl status
output, making these services behave somewhat more like normal systemd units. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this switches process oversight from Systemd to Docker itself. Is this because of Watchtower relying on docker being the process supervisor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about daemonizing the container. One of the nice things about keeping it in the foreground is that systemd can know when the container crashes and report it in
systemctl status
output, making these services behave somewhat more like normal systemd units. What do you think?
docker run
process consumes memory without doing much and breaks logging. This also makes declared containers "special" because they behave in a way that is not obvious from docker container management perspective.
Seems like this switches process oversight from Systemd to Docker itself. Is this because of Watchtower relying on docker being the process supervisor?
Yes
fa07148
to
50eff3e
Compare
50eff3e
to
6a79c61
Compare
I've tested this approach and I think it is a no go. When container is stopped with Google led me to https://github.com/DonTseTse/systemd-docker. Maybe it can solve problems you mentioned (extra process and logs). What about adding an option
? Though it is also more of a hack. |
Motivation for this change
I've had several issues with existing implementation and made some changes that was working for me for over two weeks without any problems. So this is what i've done:
Issue with logs - was: either proper logging to
journald
or workingdocker logs
, now: both working properly.Issue with redundant
docker run
in process list - fixed.Issue with containers names - was:this is fixed by #78366docker-${name}.service
, now:docker-${name}
Issue with docker tools like watchtower - was: updating container would leave service in inconsistent state, now: service would stay up as it should be.
Also ported test to python because why not (#72828).
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)cc @Atemu @benley