systemd ExecStop= Not Run #186
Comments
Important for me also. Thanks. |
This affects me too. This is really important and I'm surprised not many people are +1ing this... |
We finally tracked this down, it is a flaw in the integration between systemd and docker. For every container docker registers a systemd 'scope' in order to create a cgroup for the container. systemd kills off all scopes first thing during the shut down sequence but the documentation claims this can be disabled by disabling DefaultDepdendencies for that scope unit. However it appears that it isn't actually possible to set that property making modifying the behavior currently impossible. So unless our understanding is wrong fixing that is the first step. Email asking about this was posted recently: http://lists.freedesktop.org/archives/systemd-devel/2014-December/026313.html The second step after that will be to update docker to always set DefaultDepdendencies=false for each scope it creates. At the moment I don't know of a reasonable workaround. |
From my tinkering it seems the set-property doesn't work for properties inside the [Unit] section but only for properties in the [Scope], [Service], etc sections. I did have limited success doing the following: [Unit] DefaultDependencies=no then reload systemd (by running 'systemctl reload-daemon') |
Update on this, it is fixed in systemd upstream and I am patching Docker's libcontainer to fix it too: docker-archive/libcontainer#359 |
Great work, thanks! |
Awesome. Any idea when the changes will be released in coreos? |
@kreisys fixed in the next alpha release |
Fixed in 584.0.0. |
I have unit files for various docker services, and I would like to run a docker container before they exit. This docker container manages DNS - there could be other conceivable uses for such "utility containers".
I have the appropriate
Requires=docker.service
andAfter=docker.service
in the Unit file.The
ExecStop
command is not run until after the docker.service stops. In fact, the first thing CoreOS seems to do when shutting down is to stop running docker containers. By the time systemd gets around to the unit file, the docker container is long gone - and in my case even the docker.service has already been shut down.The implications of this issue are that no docker Unit files ever gracefully shut down as written, which seems like pretty significant flaw (even if it only affects a minority of users, since the containers themselves get shut down)..
My Unit files are below (a little worse for wear, as I have tried many different configurations)
The text was updated successfully, but these errors were encountered: