linux

docker disk usage

Find large directories

bash
du -ah / | sort -h -r | head -n 20

Find containers using a given volume

lua
docker ps -a --filter volume=<volume>

Remove container and its associated volume

bash
docker rm -v container

See total volume, image, container space

bash
docker system df

See space used per volume

bash
docker system df -v

Remove dangling volumes from disk

undefined
docker volume prune

determine which process is listening on a port

perl
sudo netstat -ltnp | grep -w ':80'

sync time

Install ntpdate

undefined
sudo apt install ntpdate

Sync

css
sudo ntpdate time.windows.com

filesystem performance is slow

workaround

Prefer ~/ over /mnt when filesystem performance is needed

wsl uses all the ram

yolo

Force linux to drop the page cache

bash
echo 1 | sudo tee /proc/sys/vm/drop_caches

limit memory assigned to WSL2 VM

Create a %UserProfile%\.wslconfig file

ini
[wsl2] memory=6GB swap=0 localhostForwarding=true

fix clock drift

WSL2 clock drifts if left open when Windows sleeps. Fix with:

undefined
sudo hwclock -s

increase number of open files

Running into EMFILE errors because too many files open? (looking at you npm i):

powershell
mylimit=8000 sudo prlimit --nofile=$mylimit --pid $$; ulimit -n $mylimit su $USER

or

bash
sudo prlimit -p "$$" --nofile=10000:10000 exec $SHELL ulimit -n 10000

posts