From a132b9167dff54aaf603b669ac0dc46f05d50d96 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Fri, 10 Apr 2026 13:31:03 +0100 Subject: [PATCH] Fix playwright-server docker image not exiting (#33099) * Fix playwright-server docker image not exiting ... by wrapping with tini * Remove redundant `npm exec` * Update packages/playwright-common/Dockerfile * missing comma --- packages/playwright-common/Dockerfile | 11 ++++++++++- packages/playwright-common/docker-entrypoint.sh | 4 +--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/playwright-common/Dockerfile b/packages/playwright-common/Dockerfile index 20bb7713a3..093d9dcf82 100644 --- a/packages/playwright-common/Dockerfile +++ b/packages/playwright-common/Dockerfile @@ -12,4 +12,13 @@ RUN npm i -g playwright@${PLAYWRIGHT_VERSION} COPY docker-entrypoint.sh /docker-entrypoint.sh -ENTRYPOINT ["/docker-entrypoint.sh"] +# We use `docker-init` as PID 1, which means that the container shuts down correctly on SIGTERM. +# +# (The problem is that PID 1 doesn't get default signal handlers, and +# playwright server doesn't register a SIGTERM handler, so if that ends up as +# PID 1, then it ignores SIGTERM. Likewise bash doesn't set a SIGTERM handler by default. +# +# The easiest solution is to use docker-init, which is in fact `tini` (https://github.com/krallin/tini). +# +# See https://github.com/krallin/tini/issues/8#issuecomment-146135930 for a good explanation of all this.) +ENTRYPOINT ["/usr/bin/docker-init", "/docker-entrypoint.sh"] diff --git a/packages/playwright-common/docker-entrypoint.sh b/packages/playwright-common/docker-entrypoint.sh index 66a71fcd58..b615bf24d6 100755 --- a/packages/playwright-common/docker-entrypoint.sh +++ b/packages/playwright-common/docker-entrypoint.sh @@ -1,4 +1,2 @@ #!/bin/bash - -# We use npm here as we used `npm i -g` to install playwright in the Dockerfile -npm exec -- playwright run-server --port "$PORT" --host 0.0.0.0 +exec /usr/bin/playwright run-server --port "$PORT" --host 0.0.0.0