[openSUSE] configure docker daemon using json configuration file #2090
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2032.
Fixes #2088.
@phillxnet, ready for review.
This pull request proposes to use the docker daemon configuration file (located at
/etc/docker/daemon.json
) to customize and configure the docker daemon with our required options, in replacement of our current docker-wrapper. Notably, these changes would be done in Rockstor-NG only, so that compatibility with CentOS Rockstor is maintained (and fully functional).This PR would thus fix two issues: #2032 and #2088.
Aims & Logic
In openSUSE flavors only (detected using
distro.id()
), this PR creates a dedicateddocker-daemon.json
file using the daemon.json file provided by the package as a template. It then updates or adds new keys and values as needed by Rockstor. These options are the same that were previously defined through our docker-wrapper:In addition, a new option related to logs has been added:
"tag": "{{.ImageName}}/{{.Name}}"
. This option is purely "cosmetic" and simply prepends all log lines coming from a container with the names of the docker image and container (see demonstration below). Although it adds more characters to each line of corresponding logs, it does help identify what container is producing those lines and allows subsequent filtering of logs by container name or image name. @phillxnet, we can easily do without this option if preferred.Once all options are defined, we write the corresponding json file in
settings.CONFROOT/docker-daemon.json
).Accordingly, we then edit the
docker.service
file to:/usr/bin/dockerd
by our docker-wrapperdata-root
as argument todockerd
--config-file
flag.This results in the
docker.service
file triggering/usr/bin/dockerd
directly (rather than through our docker-wrapper), which maintains full compatiblity of systemd control over its processes when the docker service (Rock-on service) is turned off (thereby fixing #2088).Furthermore, because the
dockerd
configurations are not defined as arguments in thedockerd
call but entirely in our newsettings.CONFROOT/docker-daemon.json
file, there is no conflict of options being defined in two different places (thereby fixing #2032).Demonstration
In openSUSE Leap15.1, configuring the Rock-on service to use the share named rockons_root and turning it on completes successfully (fixes #2032). The resulting systemd file is:
Note how the MAINPID now points to
dockerd
:Main PID: 3235 (dockerd)
.The
docker.service
file now reads:The resulting
settings.CONFROOT/docker-daemon.json
is:The rock-on service can be toggled OFF and ON repeatedly without errors (fixes #2088).
Moreover, the
journalctl
logs now shows the following details when starting the Emby server rock-on, for instance:Note how both the docker image name (
emby/embyserver:latest
) and container name (embyserver
) are detailed.Of note, the same procedure and its results have been confirmed in Tumbleweed.
In CentOS, however, everything remains the same as before and the docker-wrapper is still used.
In addition to the main logic, a small check is done on whether or not the
docker-daemon.json
file can be written, and returns a legible error in case of error:Testing
As detailed in #2088 (#2088 (comment)), the default
/etc/docker/daemon.json
is not affected by a docker package update as long as it is still present. As a result, it seems that using it as template for ourdocker-daemon.json
should be OK and won't be affected by package updates./etc/docker/daemon.json
will be replaced (as reported by @Hooverdan96) only if it does not exist at the time of the docker package update.As we wouldn't be using the docker-wrapper in openSUSE anymore, it seems important to review what it was doing and whether or not we are loosing some sanity checks (spoiler: we are not). Indeed, we had a check for:
Notably, we already have both of these checks in
docker_service.py
:Caveats & shortcomings
@phillxnet, not a real shortcoming, but let me know if you think of a better location for our
docker-daemon.jon
than its current home:settings.CONFROOT
.