Commit graph

155 commits

Author SHA1 Message Date
Yann Autissier
7f94f2b393
fix debian sysvinit script fails to restart docker daemon when stopped
Fixes: #44130
Signed-off-by: Yann Autissier <yann.autissier@gmail.com>
(cherry picked from commit 8ad8c6d887)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-21 16:32:57 +02:00
Jan Breig
bb69104381 Openrc: Depend on containerd init script
Signed-off-by: Jan Breig <git@pygos.space>
2022-06-01 15:09:52 +02:00
Michael Kuehn
60f868c263
Ensure system clock was set
Single-Board Computer and embedded systems might have a clock that is extremely out of sync with reality.
Adding this target ensures docker is only started after a somewhat realistic clock was set.
More information about the time-set.target can be found here: https://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target

Signed-off-by: Michael Kuehn <micha@kuehn.io>
2021-12-24 16:08:53 +01:00
Tianon Gravi
a985655ac4 Move containerd.service from Requires= to Wants=
Per the systemd.unit documentation:

> If this unit gets activated, the units listed will be activated as well. If one of the other units fails to activate, and an ordering dependency After= on the failing unit is set, this unit will not be started. Besides, with or without specifying After=, this unit will be stopped if one of the other units is explicitly stopped.
>
> Often, it is a better choice to use Wants= instead of Requires= in order to achieve a system that is more robust when dealing with failing services.

This should also be generally "safe" given we added `--containerd=/run/containerd/containerd.sock` to the flags we pass to `dockerd`.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-07-12 10:06:35 +00:00
Sebastiaan van Stijn
35c1542ec7
contrib: remove unused "rpm" variant of systemd unit
This unit file was created when we packaged rpms without the
socket activation unit, but that's no longer the case.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-05-12 11:58:13 +02:00
Sebastiaan van Stijn
11dd2b79b9
Merge remote-tracking branch 'packaging_tmp/master' into upstream_systemd_units
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-05-12 11:57:30 +02:00
Sebastiaan van Stijn
5458b0e435
Revert "Add multi-user.target to After="
This reverts commit 0ca7456e52,
which caused the docker service to not be starting, or delayed
starting the service in certain conditions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-12-10 15:04:00 +01:00
Sebastiaan van Stijn
273eae8a11 Revert "systemd: add multi-user.target to After list"
This reverts commit a65c65d801,
which caused the docker service to not be starting, or delayed
starting the service in certain conditions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-12-10 14:53:03 +01:00
Michał Kosek
009639e0f4 Do not "Bind" docker "To" containerd.
relates to https://github.com/docker/for-linux/issues/678

When using the BindTo directive, Docker is permanently stopped by systemd
when containerd is temporarily killed and restarted;

Using `Requires` achieves mostly the same, but defines a weaker dependency;

https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requires=

> Requires=
>
> .. If this unit gets activated, the units listed will be activated as well.
> If one of the other units fails to activate, and an ordering dependency
> After= on the failing unit is set, this unit will not be started. Besides,
> with or without specifying After=, this unit will be stopped if one of the
> other units is explicitly stopped.

We may want to look into using `Wants=` instead of `Requires=`, because
that allows docker to continue running if containerd is restarted, quoting
the systemd documentation:

> Often, it is a better choice to use Wants= instead of Requires= in order
> to achieve a system that is more robust when dealing with failing services.

Given that docker will likely still fail if the containerd socket is not
present, startup will fail if containerd is not running, but if containerd
is restarted, the docker daemon may be able to try reconnecting.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-11-04 14:01:17 +01:00
Sebastiaan van Stijn
21578530d7 systemd: set OOMScoreAdjust for dockerd
dockerd currently sets the oom-score-adjust itself. This functionality
was added when we did not yet run dockerd as a systemd service.

Now that we do, it's better to instead have systemd handle this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-10-05 20:08:26 +02:00
Isaiah Grace
a65c65d801 systemd: add multi-user.target to After list
Signed-off-by: Isaiah Grace <irgkenya4@gmail.com>
2020-07-29 17:13:04 -04:00
Isaiah Grace
0ca7456e52 Add multi-user.target to After=
Add multi-user.target to the After= list in docker.service so that multi-user.target does not wait for docker.service (and consequently wait for network-online.target).

Signed-off-by: Isaiah Grace <irgkenya4@gmail.com>
2020-07-29 14:33:55 -04:00
Sebastiaan van Stijn
32b4590b23
contrib: remove REVIEWERS files
We were not really using these, and they haven't been
updated in a long time. If needed, we can add people to
the CODEOWNERS file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-06-24 12:12:09 +02:00
Sebastiaan van Stijn
d339e6d480 Don't disable socket activation when stopping docker service
PartOf deactivates the socket whenever the service get deactivated.
The socket unit however should be active nevertheless, so that the
docker service can be started again through socket activation.

Based on the original patch in upstream moby/moby by Max Harmathy.

Co-authored-by: Max Harmathy <max.harmathy@web.de>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-04 13:19:42 +01:00
Akihiro Suda
3cf82748dd run shfmt
git grep --name-only '^#!' | egrep -v '(vendor|\.go|Jenkinsfile)' | xargs shfmt -w -bn -ci -sr

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-03-03 12:27:49 +09:00
Akihiro Suda
7af0344f9b
Merge pull request #37470 from harmathy/patch-1
Allow socket activation
2020-03-03 10:48:21 +09:00
Wiktor Kwapisiewicz
8abf26dbfb
Change docker socket location to /run/docker.sock
This change resolves the following systemd warning:

```
/usr/lib/systemd/system/docker.socket:5: ListenStream= references a path below legacy directory /var/run/, updating /var/run/docker.sock → /run/docker.sock; please update the unit file accordingly.
```

Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
2019-05-28 23:22:54 +02:00
Manuel Rüger
275677e94f openrc: Modernize and sync settings
* Use rc_ulimit for ulimit constraints
* Synchronize ulimit settings to systemd's
* Add support for reload command
* Add support for retry settings for docker stop/restart

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2019-04-02 15:06:49 +02:00
Michael Hudson-Doyle
cfde9c717f systemd: fix typo in TasksMax comment 2019-02-27 12:49:17 +13:00
Sebastiaan van Stijn
23c763ef1c systemd: set --containerd socket patch to prevent race-condition
containerd is now running as a separate service, and should
no longer be started as a managed child-process of dockerd.

The dockerd service already specifies that it should be started
`After` the containerd.service, but there is still a race
condition, where containerd is started, but its socket is not yet
created.

In that situation, `dockerd` detects that the containerd socket
is missing, and will start a new instance of containerd (as a
managed child-process), which causes live-restore to fail.

This patch explicitly sets the `--containerd` daemon option.
If this option is set, `dockerd` will not start a new instance
of containerd.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-02-11 14:36:48 +01:00
corbin-coleman
d021af7d2d Start docker.service after containerd.service
Signed-off-by: corbin-coleman <corbin.coleman@docker.com>
2019-01-14 23:27:51 +00:00
Eli Uriegas
a937bc3825 Add docker.socket requirement for docker.service
Without this the docker.socket would not start by default when starting
the docker.service leading to failures to start.

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-12-03 19:14:10 +00:00
Eli Uriegas
6821d80881 Add socket activation for RHEL based distributions
Removes the systemd drop-in unit file for socket activation and instead
prefers socket activation by default for both RHEL based and DEBIAN
based distributions.

Socket activation for RHEL based distributions was tested on CentOS 7 and Fedora 28.

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-11-29 00:47:07 +00:00
Eli Uriegas
07c9fef311 Add the docker.socket back in
Re-adds the docker.socket file for debian based distributions.

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-11-15 00:57:19 +00:00
Valentin Kulesh
0fa3c8c277 Restore Type=notify in Systemd unit
Signed-off-by: Valentin Kulesh <valentin.kulesh@virtuozzo.com>
2018-10-08 21:51:26 +03:00
Eli Uriegas
b19e8d3319 Remove Environment, not needed anymore
Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-09-26 18:15:23 +00:00
Eli Uriegas
212521b1e9 Use image artifacts as daemon and dependencies
Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-09-21 22:03:21 +00:00
Kir Kolyshkin
14103caff2 systemd/docker.service: fix PATH
Set the PATH to what appears to be the standard on latest Ubuntu (18.04)
and Debian (9), fixing the following two issues:

1. PATH did not contain /bin (leading to ContainerTop/ps not working
on newer distros, among the other things).

2. $PATH can't be specified in Environment directives in .service files.

While at it, also:

3. Remove the comment about RPM as it looks misleading on deb-based
systems.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-09-20 10:19:35 -07:00
Eli Uriegas
ea996b88c1 Add /usr/sbin to our path variable for systemd
iptables is sometimes placed in `/usr/sbin`

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-09-17 10:16:37 -07:00
Eli Uriegas
09e8b411dc Remove offline installer to install shim-process
Removes the need for the offline installer to install the shim process
and instead installs the shim process as part of the packaging.

May be easier in the future to just package the shim process on it's own
but that'll come after this 18.09 release

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-09-10 09:10:37 +00:00
Sebastiaan van Stijn
cb95442fc7 systemd: set start burst limits
Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229
(6bf0f408e4)
both the old, and new location are accepted by systemd 229 and up, so using the old location
to make them work for either version of systemd.

StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230
(f0367da7d1)
both the old, and new name are accepted by systemd 230 and up, so using the old name to make
this option work for either version of systemd.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-08-31 15:19:15 +02:00
Sebastiaan van Stijn
e7ad8e2b28 systemd: add support for reloading daemon configuration through systemd
This adds support for reloading the docker daemon
(SIGHIUP) so that changes in '/etc/docker/daemon.json'
can be loaded at runtime by reloading the service
through systemd ('systemctl reload docker')

Before this change, systemd would output an error
that "reloading" is not supported for the docker
service;

  systemctl reload docker
  Failed to reload docker.service: Job type reload is not applicable for unit docker.service.

After this change, the docker daemon can be reloaded
through 'systemctl reload docker', which reloads
the configuration;

  journalctl -f -u docker.service

  May 02 03:49:20 testing systemd[1]: Reloading Docker Application Container Engine.
  May 02 03:49:20 testing docker[28496]: time="2016-05-02T03:49:20.143964103-04:00" level=info msg="Got signal to reload configuration, reloading from: /etc/docker/daemon.json"
  May 02 03:49:20 testing systemd[1]: Reloaded Docker Application Container Engine.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-08-31 15:11:28 +02:00
Sebastiaan van Stijn
f30757f439 systemd: set systemd KillMode
Change the kill mode to process so that systemd does not kill container
processes when the daemon is shutdown but only the docker daemon

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-08-31 15:11:21 +02:00
Sebastiaan van Stijn
26eddc16a8 systemd: add "Delegate=yes" to docker's service file
We need to add delegate yes to docker's service file so that it can
manage the cgroups of the processes that it launches without systemd
interfering with them and moving the processes after it is reloaded.

       Delegate=
           Turns on delegation of further resource control partitioning to
           processes of the unit. For unprivileged services (i.e. those
           using the User= setting), this allows processes to create a
           subhierarchy beneath its control group path. For privileged
           services and scopes, this ensures the processes will have all
           control group controllers enabled.

This is the proper fix for issue moby/moby#20152

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-08-31 15:11:16 +02:00
Sebastiaan van Stijn
7daf2db62a systemd: don't limit tasks
Systemd sets a default of 512 tasks, which is far
too low to run many containers.

Note that TasksMax is only supported on systemd 226
and above.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-08-31 15:11:11 +02:00
Sebastiaan van Stijn
80039b4699 systemd: set Limit* to infinity
There is a not-insignificant performance overhead for all containers (if
containerd is a child of Docker, which is the current setup) if systemd
sets rlimits on the main Docker daemon process (because the limits
propogate to all children).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-08-31 15:11:05 +02:00
Sebastiaan van Stijn
ef9ee10914 systemd: no limit on core size
set LimitCORE=infinity to ensure complete core creation,
allows extraction of as much information as possible.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-08-31 15:10:57 +02:00
docker-unir[bot]
ffc5810932 Merge pull request #168 from crosbymichael/prestart
Merged with https://github.com/seemethere/unir
2018-08-28 23:20:49 +00:00
Andrew Hsu
53343f1bf3 added RestartSec
Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
(cherry picked from commit 51879873897afe298cbb736acef34b5a0b500424)
Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
2018-08-28 19:56:36 +00:00
Michael Crosby
0c8e758012 Add post-stop
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-28 13:51:21 -04:00
Eli Uriegas
e56475aa14 Set containerd to be a systemd bind for docker
The daemon won't actually start without containerd

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-08-20 21:17:32 +00:00
Eli Uriegas
cdb1e7033d Some changes to get this working on CentOS 7
Old versions of things on CentOS 7 strike again!

infinity is not a thing for TimeoutSec on systemd < 229

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-08-16 04:03:40 +00:00
Eli Uriegas
e086064b2c Revive pre / post steps, update offline location
Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-08-15 23:17:54 +00:00
Eli Uriegas
a5c809e809 Round out systemd for RPM packaging
Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-08-15 23:01:10 +00:00
Eli Uriegas
6cd66eaa2d Add systemd files, add containerd-proxy config
Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2018-08-14 20:30:22 +00:00
Max Harmathy
28e93ed8ca
Allow socket activation
PartOf deactivates the socket whenever the service get deactivated. The socket unit however should be active nevertheless.

Signed-off-by: Max Harmathy <max.harmathy@web.de>
2018-07-16 14:36:02 +02:00
Eli Uriegas
b8bcf7005c Use internal systemd scripts for DEB packaging
Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2017-06-06 14:56:39 -07:00
Eli Uriegas
bb68bc5ae2 Add initial systemd scripts
Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2017-06-06 11:32:27 -07:00
William Hubbs
65c1a3be5b contrib/init/openrc: allow separate logs for stdout and stderr
Signed-off-by: William Hubbs <w.d.hubbs@gmail.com>
2017-02-23 17:07:26 -06:00
Alexander Morozov
ea4d124395 Merge pull request #30210 from thaJeztah/carry-29727
[carry 29727] update unit-file; wait for network to be online
2017-02-03 17:17:08 -08:00