Signed-off-by: Cory Snider <csnider@mirantis.com>
| ... | ... |
@@ -386,9 +386,6 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \ |
| 386 | 386 |
dbus-user-session \ |
| 387 | 387 |
systemd \ |
| 388 | 388 |
systemd-sysv |
| 389 |
-RUN mkdir -p hack \ |
|
| 390 |
- && curl -o hack/dind-systemd https://raw.githubusercontent.com/AkihiroSuda/containerized-systemd/b70bac0daeea120456764248164c21684ade7d0d/docker-entrypoint.sh \ |
|
| 391 |
- && chmod +x hack/dind-systemd |
|
| 392 | 389 |
ENTRYPOINT ["hack/dind-systemd"] |
| 393 | 390 |
|
| 394 | 391 |
FROM dev-systemd-${SYSTEMD} AS dev
|
| 395 | 392 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,62 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+set -e |
|
| 2 |
+container=docker |
|
| 3 |
+export container |
|
| 4 |
+ |
|
| 5 |
+if [ $# -eq 0 ]; then |
|
| 6 |
+ echo >&2 'ERROR: No command specified. You probably want to run `journalctl -f`, or maybe `bash`?' |
|
| 7 |
+ exit 1 |
|
| 8 |
+fi |
|
| 9 |
+ |
|
| 10 |
+if [ ! -t 0 ]; then |
|
| 11 |
+ echo >&2 'ERROR: TTY needs to be enabled (`docker run -t ...`).' |
|
| 12 |
+ exit 1 |
|
| 13 |
+fi |
|
| 14 |
+ |
|
| 15 |
+env > /etc/docker-entrypoint-env |
|
| 16 |
+ |
|
| 17 |
+cat > /etc/systemd/system/docker-entrypoint.target << EOF |
|
| 18 |
+[Unit] |
|
| 19 |
+Description=the target for docker-entrypoint.service |
|
| 20 |
+Requires=docker-entrypoint.service systemd-logind.service systemd-user-sessions.service |
|
| 21 |
+EOF |
|
| 22 |
+ |
|
| 23 |
+quoted_args="$(printf " %q" "${@}")"
|
|
| 24 |
+echo "${quoted_args}" > /etc/docker-entrypoint-cmd
|
|
| 25 |
+ |
|
| 26 |
+cat > /etc/systemd/system/docker-entrypoint.service << EOF |
|
| 27 |
+[Unit] |
|
| 28 |
+Description=docker-entrypoint.service |
|
| 29 |
+ |
|
| 30 |
+[Service] |
|
| 31 |
+ExecStart=/bin/bash -exc "source /etc/docker-entrypoint-cmd" |
|
| 32 |
+# EXIT_STATUS is either an exit code integer or a signal name string, see systemd.exec(5) |
|
| 33 |
+ExecStopPost=/bin/bash -ec "if echo \${EXIT_STATUS} | grep [A-Z] > /dev/null; then echo >&2 \"got signal \${EXIT_STATUS}\"; systemctl exit \$(( 128 + \$( kill -l \${EXIT_STATUS} ) )); else systemctl exit \${EXIT_STATUS}; fi"
|
|
| 34 |
+StandardInput=tty-force |
|
| 35 |
+StandardOutput=inherit |
|
| 36 |
+StandardError=inherit |
|
| 37 |
+WorkingDirectory=$(pwd) |
|
| 38 |
+EnvironmentFile=/etc/docker-entrypoint-env |
|
| 39 |
+ |
|
| 40 |
+[Install] |
|
| 41 |
+WantedBy=multi-user.target |
|
| 42 |
+EOF |
|
| 43 |
+ |
|
| 44 |
+systemctl mask systemd-firstboot.service systemd-udevd.service |
|
| 45 |
+systemctl unmask systemd-logind |
|
| 46 |
+systemctl enable docker-entrypoint.service |
|
| 47 |
+ |
|
| 48 |
+systemd= |
|
| 49 |
+if [ -x /lib/systemd/systemd ]; then |
|
| 50 |
+ systemd=/lib/systemd/systemd |
|
| 51 |
+elif [ -x /usr/lib/systemd/systemd ]; then |
|
| 52 |
+ systemd=/usr/lib/systemd/systemd |
|
| 53 |
+elif [ -x /sbin/init ]; then |
|
| 54 |
+ systemd=/sbin/init |
|
| 55 |
+else |
|
| 56 |
+ echo >&2 'ERROR: systemd is not installed' |
|
| 57 |
+ exit 1 |
|
| 58 |
+fi |
|
| 59 |
+systemd_args="--show-status=false --unit=docker-entrypoint.target" |
|
| 60 |
+echo "$0: starting $systemd $systemd_args" |
|
| 61 |
+exec $systemd $systemd_args |