Skip to content

Instantly share code, notes, and snippets.

@larkinwc
Created February 16, 2025 21:17
Show Gist options
  • Save larkinwc/80d35db5931644412afea663a73d97a5 to your computer and use it in GitHub Desktop.
Save larkinwc/80d35db5931644412afea663a73d97a5 to your computer and use it in GitHub Desktop.
Script to fix docker running in WSL if it crashes and won't start again with the message "/etc/init.d/docker: 62: ulimit: error setting limit (Invalid argument)"
#!/bin/bash
# Check if script is run as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root (use sudo)"
exit 1
fi
echo "Setting ulimit..."
ulimit -n 524288
echo "Starting Docker service..."
service docker start
# Check if Docker started successfully
if [ $? -eq 0 ]; then
echo "Docker has been started successfully!"
else
echo "Error: Docker failed to start"
exit 1
fi
@larkinwc
Copy link
Author

larkinwc commented Feb 16, 2025

If ulimit is not found, try running sudo su and executing again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment