SERVER-113605: Set coredump kernel param on container initialization (#43743)

GitOrigin-RevId: 86c3873be8e3b721990fae3af9681bd0cbd1c108
This commit is contained in:
Eric Lavigne
2025-11-18 11:14:37 -07:00
committed by MongoDB Bot
parent 6be3b3cec1
commit fd3b0ab6a4
3 changed files with 30 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
"runArgs": [
"--name=mongo-dev-${containerWorkspaceFolderBasename}-${devcontainerId}"
],
"initializeCommand": "${localWorkspaceFolder}/.devcontainer/initialize.sh",
"build": {
"dockerfile": "./Dockerfile",
"context": "..",

18
.devcontainer/initialize.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# MongoDB Development Container Host Initialization Script
# This script runs on the host machine before the container starts.
set -euo pipefail
# Configure core dump pattern in the Docker VM
# This is a kernel-level setting that cannot be modified from within unprivileged containers,
# so we use nsenter to enter the Docker VM's mount namespace and set it there.
echo "Configuring core dump pattern in Docker VM..."
docker run --rm --privileged --pid=host \
alpine:3.22.2@sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412 \
nsenter -t 1 -m -- sh -c "echo 'dump_%e.%p.core' > /proc/sys/kernel/core_pattern" \
2>/dev/null || {
echo "Warning: Could not set core dump pattern (this is expected on non-Docker Desktop environments)"
}
echo "Host initialization complete"