In this context, 'dog' is used informally to describe someone who is rude or considered bad.
Don't be such a dog.
He is acting like a dog.
In this sense, 'dog' refers to a person who is exceedingly loyal or faithful, drawing on the reputation of dogs as loyal pets.
He's a good dog for sticking by my side.
She is a loyal dog.