Sounds like pain and the he definitely needs a vet asap
Ahh, poor pup. My dog when she got older had a chronic pain. But it would flare. When it did, she'd hid under my bed and cry when I tried to get her out. They did prescribe a tablet to be taken AS NEEDED for her. It was a pain reliever. It would allow her to feel better, rest and she lived for several years only taking it occasionally when needed. Probably five extra years. She died at 18 years old! How old is your dog?
I agree with specialmom, that if he is in pain, there could be a pain relief medicine which could help him. That would be worth a try, I think.
Maybe he has a stiff back, or some bulging disk or something? I know Doxies can get that commonly.
Does he show other signs of pain? Even though he is an old fella. Such as being unwilling to move, or eat? Can he get out quite well to do his business? Does he yelp at all if he is touched, picked up, or when he moves? Does he basically have a fairly decent quality of life? (Eating, drinking, doing business, sleeping okay, interacting with loved ones....even if he is slower or not active for many hours of the day (as old ones often sleep more.)
His moaning might be pain, and I think it's a good idea to take him to the vet for some "palliative" care which he might benefit from.
You could make it clear perhaps that you don't want him to suffer invasive procedures, but if there is some pain relief that might make his old age a bit easier, then you could try it.
On the other hand his moaning might be breathing problems, or possibly even calls for attention? The old ones can sometimes get a bit clingy like that.
And some dogs do moan in their sleep (if it happens during sleep.)
But a check over at the vet's might help him.
Their last months/ weeks or however much time we have left with them, are always hard on us. We see them drawing close to their passing day by day, and that makes us sad. But while they may still have some valuable and happy times left with us, we can make the most of those times.
Kind thoughts to you and your little one.