There are 2 ways to use docking ports to build a spacecraft that can rendezvous with another in orbit
First we have a TR-18A Stack Decoupler flipped upside down (you can tell by the red arrow which side will detach), with a Docking Port attached underneath it.
You will notice many EAS-4 Strut connectors used here. Those are for payload stability during takeoff. Don't worry, they disappear when you decouple the node. (let's imagine they have explosive bolts in them like everything else in our rockets)
On top of the lander, we have a Shielded Clamp-o-tron Docking Port. After achieving a parking orbit, the way it works is you decouple the lander, flip it around 180°, (remember to open the shield!) and dock with your fuel tank. Presto! Remember to turn the lander's engines off before trying a burn.
This is very similar to the way the Apollo missions did it. (but not on purpose, I didn't know how Apollo worked until after I built my rocket! After a few refinements, mine just turned out like this :)
When building, Shielded docking ports seem to attach very well on TOP of things, while regular ol' docking ports attach well UNDERNEATH things. That seems to be the way the game likes it, and it's best not try to build something unnatural. You will get weird effects on your spacecraft (like uncontrollable spinning) that may force an emergency landing, for Jeb's sake.
Note that when you hit the stage for the stack decoupler of your lander, you will also have to right click the docking port and ask it to "decouple" there as well. Otherwise, they will still be stuck together. One way I found to prevent this is to set up custom action groups.
I set up group 1 (the 1 key on your keyboard) to set off both the stack decoupler AND the "decouple" option on the docking port to ensure separation.
I call this the "Non-reattachable method" because once you decouple the lander, you can't reattach it in the same place again. Which is fine, since we already put another docking port on top!
Yes, I am making these terms up. Launching this way with two docking ports is only really necessary if you can't fit a Shielded docking port on top, or you want the payload to have two docking ports, top and bottom, as with this orbital Mobile Processing Lab.
Again, you will notice the liberal use of strut connectors for stability. Because there are no stack decouplers at all here, the only way to detach these is with a right-click decouple command.
Remember when building things should snap into place. The first docking port you have to turn upside down, (rotate parts with WASD keys) and the next docking port should snap onto it immediately.
It may look unstable, but with enough
duct tape reinforcements just about anything will fly!