It is somewhat subtle, but "aber" is more negative, while "doch" would be "jedoch" when used as "but". I'll try to show you with an example (in English: "I'm learning, but I would rather sleep.")
"Ich lerne, aber ich möchte lieber schlafen." is much more 'confrontational' than "Ich lerne, jedoch möchte ich lieber schlafen.". HOWEVER the second one is much more normal - in any casual conversation the first one is totally fine.
Like I said it's a subtle difference...I hope I could help and if not feel free to ask again.