If you run dedicated game servers via Pterodactyl (such as No More Room in Hell or other Source Engine games), you will eventually hit a familiar limitation: the server container runs as an unprivileged user (container, UID 1000). You have no root privileges and no package manager inside the container to install missing system utilities.
Some Sourcemod extensions, crash-reporting tools, or custom monitor scripts require lsof to check open sockets and files. Here is a clean workaround to extract lsof on the host machine and inject the binary directly into your container's persistent storage without rebuilding the Docker image.
Step 1: Download and Extract the Debian Package on the Host
Log in as root on your server host. Instead of installing lsof system-wide, download the official .deb package into a temporary directory and extract its contents:
apt-get download lsof
mkdir -p /tmp/nmrih-lsof
dpkg-deb -x lsof_*.deb /tmp/nmrih-lsof
This unpacks the binary to /tmp/nmrih-lsof/usr/bin/lsof along with any included documentation.
Step 2: Copy the Binary to the Server Volume
Pterodactyl mounts server data from the host filesystem into /home/container inside Docker. Depending on your daemon configuration, this usually lives under /var/lib/pterodactyl/volumes/<uuid> or a custom directory like /home/daemon-data/<uuid>.
Create a dedicated bin folder in that server's root volume and copy the extracted binary there:
# Replace the UUID with your actual server directory
mkdir -p /home/daemon-data/badd9299-9a22-4d3a-9bad-bb7cee337464/bin
cp /tmp/nmrih-lsof/usr/bin/lsof \
/home/daemon-data/badd9299-9a22-4d3a-9bad-bb7cee337464/bin/lsof
chmod 755 /home/daemon-data/badd9299-9a22-4d3a-9bad-bb7cee337464/bin/lsof
Step 3: Check Shared Library Dependencies
Verify whether the binary has any missing dynamically linked libraries that the container environment might lack:
ldd /home/daemon-data/badd9299-9a22-4d3a-9bad-bb7cee337464/bin/lsof
On modern Debian/Ubuntu bases, lsof links against standard libc and libselinux. As long as your host OS version roughly matches the container base image, all libraries will resolve cleanly.
Step 4: Test Execution Inside the Running Container
Find your running container ID:
docker ps
Then test running the newly copied binary from within the container context:
docker exec 7e70ffd45273 /home/container/bin/lsof -v
If you see version output, the binary is executable and compatible with the container's environment.
Step 5: Prepend the Binary to Your Startup Script
Inside the container, applications look for binaries in standard paths like /usr/bin. To let your game server script find lsof without specifying full paths every time, prepend /home/container/bin to your PATH variable.
In Pterodactyl's Startup tab (or in your launch script), update your start command:
export PATH="/home/container/bin:$PATH"; ./srcds_run -game nmrih
Now any script or plugin launched by srcds_run will find and execute lsof properly, with zero changes to your base Docker image or Pterodactyl egg.