Edit: changed from "After setting USER, programs often expect ENV HOME to be set"
When switching USER in a Dockerfile, it would be awesome if Docker checked to see if the home directory exists, and if so: autorun this Dockerfile command:
ENV HOME /home/$(whoami)
I don't know linux/ubuntu user internals at all, but I imagine there are other automatically set variables that are getting missed, too.
$HOME being "/" bit me when trying to run a bower install, which expects $HOME to be a writeable directory, which / was not for my active user.
If setting $HOME is impractical or undesirable, a doc note in the USER section to also run an ENV HOME would be very helpful.