Walk up to the dog from the side, not the back or directly in front.
Hold out your knuckle and let him sniff your hand, this method keeps your fingers protected. That's how dogs tell who you are by sniffing. Pat him under his chin or on the side. Never pat a dog by coming down over the top of his head or the back of his neck because it is threatening. Practice by patting your pet dog correctly.