Skip to content

Instantly share code, notes, and snippets.

@sjug
Last active January 20, 2021 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjug/d0c1a588ed1cc4ca1d62a59b61bb8685 to your computer and use it in GitHub Desktop.
Save sjug/d0c1a588ed1cc4ca1d62a59b61bb8685 to your computer and use it in GitHub Desktop.
How podman sets ulimits
#!/bin/bash
DEFAULT_CORE_LIMIT=512
SOFT_CORE_LIMIT="${1:-${DEFAULT_CORE_LIMIT}}"
HARD_CORE_LIMIT="${2:-${DEFAULT_CORE_LIMIT}}"
echo "Starting test container with core ulimit of ${SOFT_CORE_LIMIT}:${HARD_CORE_LIMIT}"
sudo podman run -d --rm --ulimit core=${SOFT_CORE_LIMIT}:${HARD_CORE_LIMIT} quay.io/libpod/fedora-minimal:latest sleep 1
echo
ULIMIT_PID=$(pgrep sleep)
PARENT_PID=$(ps -o ppid= -p ${ULIMIT_PID})
PARENT_CMD=$(ps -o command= ${PARENT_PID})
PID_LIMITS=$(cat /proc/${ULIMIT_PID}/limits | awk 'NR==1 || /core/')
echo -e "PID with ulimit set: ${ULIMIT_PID}\n"
echo "Parent PID: ${PARENT_PID}"
echo -e "Parent CMD:\n${PARENT_CMD}\n"
echo -e "Core limit of PID:\n${PID_LIMITS}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment