Containerized Python worker aborts with SIGABRT only when launched from systemd timer unit
Environment
Ubuntu 22.04 host, Docker 20.10.25, Python 3.11 image with a compiled C-extension used by worker. systemd timer configured to run docker run --rm myworker:latest on schedule (Type=oneshot, launched as root).
Symptoms
When systemd timer triggers, the container starts but the worker process inside receives SIGABRT then exits; container stops with exit code 134. Running identical docker run command interactively from shell succeeds and worker runs to completion.
Observations
journalctl shows systemd unit finished; no OOM killer entries in dmesg or syslog. Core produced inside container points to abort in native extension (abort()). Running docker run under sudo in an interactive non-login shell works. Adding --init to docker run didn't change behaviour when started via timer. No AppArmor denials logged.
Already attempted
Increased systemd limits (LimitNOFILE, TasksMax), tried launching timer as a different user, ran container with --privileged and added CAP_SYS_ADMIN; replicated environment variables from interactive shell in unit file; used docker logs and docker inspect. None consistently prevented SIGABRT.
Question
Which environment or cgroup differences imposed by systemd timers commonly cause process aborts inside containers? How can I safely reproduce the systemd-start environment for iterative debugging and identify the failing subsystem in the C-extension without rebuilding production images?
Verified community troubleshooting
Start by reproducing the systemd-start environment locally: run systemd-run --scope --unit=tmpdocker /usr/bin/docker run ... so you get the same cgroup/limits. If the container still aborts, add a tiny wrapper script as the container ENTRYPOINT that writes env and /proc/self/limits to a mounted directory before launching the worker — compare that with your interactive run. If ulimits differ, set LimitNOFILE/TasksMax in the unit; if env vars are missing, add Environment= or EnvironmentFile=. Verify by running the timer for several iterations and checking the saved logs. Roll back any raised limits if they cause resource exhaustion on the host.
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Linux23% match
systemd service ExecStart script returns 'Permission denied' only when run as non-root user after unit file move
Open0 answers - Linux22% match
Docker containers lose DNS after host switched to systemd-resolved stub resolver on Ubuntu 22.04
Solved1 answer - Linux21% match
Ubuntu 22.04: Docker containers intermittently lose DNS after host switches to systemd-resolved stub resolver during network changes
Solved1 answer - Cloud Computing21% match
Self-hosted GitHub Actions runner cannot access /var/run/docker.sock when launched as systemd service
Solved1 answer