You have to ask yourself what is your job in the office and do it sincerely. This is your prime aim and duty. It feels good if your boss is nice to you. If not try to detach yourself from your boss's behaviour focussing on your work. As it is he is a little unpredictable. Not necessarily his behaviour is related to you or anybody else as your colleagues have observed. The root cause may be within him or his personal sphere. You do not have to blame yourself if there is no evidence. Try to relax by deep breathing or pranayam, distract yourself from his thoughts, spend time with your family and friends or in your hobbies. Talk to your colleagues to learn about how they deal with this problem. If these do not help consult a psychologist or a psychiatrist.