Understand, fact that your boss, like yourself, is a human being. Like everyone else, bosses come in all shapes and sizes. Like you, he has ambitions, aspirations, and dreams. Some he will achieve, others he won't. Some bosses are good managers, others bad, but most fall somewhere in middle range.
Unless you're working for a very small company, your boss probably has superiors of his own - that no doubt can, and do, drive him crazy at times. What it boils down to more than anything else is, how well you and your boss can deal with emotional roller coaster of everyday life, and perhaps most importantly, how each of you view your job.
To get along with you boss, or other people for that matter, you have to know how to understand and react to personality traits, get inside your boss's head. In short, you need to develop your human relations skills.
This does not mean becoming a ""yes" man and always siding with your boss no matter how dumb a mistake he makes, or how big a fool he makes of himself. Your boss may appreciate such blind devotion, but unless you are willing to drop anchor and never advance up corporate ladder, you also need to know when to put some distance between you immediate supervisor, and powers that be, because if your boss really goofs-up - you may be shown door at same time your boss is!
Back to getting along with boss, you of course need to get on and stay on his "good side," in short become a team player That means becoming type of an employee everyone would like to have work for them. Someone with a positive outlook, someone who's also friendly, loyal, tolerant, compassionate, understanding, courteous and supportive. Someone who can take, and follow orders. Someone who can get job done. Someone who knows when to speak-up, and when to keep his mouth shut.
Regardless of what you think of your boss, first thing you should learn, is his style of supervising. The two extremes of management style, are a boss who enjoys playing part of a military leader, where he, or she barks orders that must be followed exactly without question, or boss who maintains a very low profile, giving employees broad guidelines and then disappearing. Fortunately, most bosses fall somewhere in between two extremes, or little actual work would ever get done!
If you have type of personality that demands you must have very specific orders or you're "afraid you won't do it right," you better have a boss who is willing to spend time watching your every step.
On other hand, if you must be left to your own devices to make things work to get job done and resent boss looking over your shoulder or constantly "picking on you," you better have type of boss who is willing to give you enough room to do your own thing.
Either way, if you are stuck with "wrong kind" of boss it will be a real source of irritation that frequently ends in you not seeing eye to eye with your supervisor.
If you can't change, or at least try, you would be better off finding employment elsewhere - because boss isn't going to change his management style to please you!
It also pays dividends to learn what your boss likes and dislikes, and then adapt what you do to suit his personality and management style. All bosses expect their workers to know how to do their job, and to get it do it correctly, and on time, but problems are bound to come up in any business. One thing that can really "set off" your boss is not handling problems like "he thinks" they should be handled.