Dome light...

Can anyone help me figure out why my dome light one turn off after closing the door? I took the bulb out and put it back in and it works fine the first two times and after that it stays on again???