Suspend/Resume problems Docker containers

Once upon a time, while using Debian I had a problem with Docker containers and suspend/resume.

Docker resume/thaw problems?

When you use Docker containers on your development system and experience problems after a resume from a suspend (or a thaw from a hibernate). On my Debian Stable KDE system –after a resume of my MongoDB and WildFly containers– the screensaver did not ask for a password and the computer did not respond to mouse and keyboard.

Fix via pm-utils script

A pm-utils script can be added to pause all running Docker containers on suspend /hibernate and unpause them on resume/thaw. Create a file /usr/lib/pm-utils/sleep.d/00docker with following content:

 3command_exists docker || exit $NA
 4# Pause all running docker containers on suspend|hibernate and unpause on resume|thaw.
 5case $1 in
 6    suspend|hibernate) docker pause $(docker ps -q) ;;
 7    resume|thaw)       docker unpause $(docker ps -q) ;;
 8    *) exit $NA ;;
10exit 0

Posts in this Series