For the in-game docking tutorial, see Tutorial 3.
Docking is one of the most important things to learn in Space Agency. Docking appears frequently in missions, like Mission 2, 9, etc. You could make space stations, larger space crafts by docking. This is a tutorial to help you if you don't know how to dock.
Step 1: Creating the spacecraft
First of all, make a space craft that contains a payload that is dockable. The payload can be anything, depending on what you want to make. If they are carrying the same payload, it is suggested that if you are using two different rockets, they should both use the same rocket design. Because, while the first rocket might fail, it was the most effective design and time will be wasted attempting to recreate it. Also note that in missions, the space ships will have different "heights," so remember to make the second/third stage (or your maneuvering stage) a part that is maneuverable (tugs, CSM, etc).
Step 2: Manouevering
If the ships are already on the same orbital line, just skip to step 3.
After launching both spacecrafts into orbit, it's time to maneuver the 1st/2nd spacecraft downwards/upwards and fire the engine until the red orbit circle touches the spacecraft you want to dock. Doing this because even if you stop the engines, the orbit will still move smaller/ bigger for a little bit. Try changing it if neccessary. Notice that the smaller the orbit is, the faster you go even if your velocity is the same as a spaceship in a larger orbit.
Step 3: Docking
After aligning the two spaceships together, fire the engines a little bit on the one one the back and try not to overdo it. If you didn't release the payload on the front then do it now. Carefully slow the spaceship on the back using propellant. Slowly, dock them together. If you didn't do it the first time, try again. After you docked, just press the staging button to seperate them.
Out of Orbit Docking
Step Two: Departure
Once your red heading vector is lined up with the waypoint to which you want to travel, immediately press the thrust button until your velocity is red and you leave the Circle of Influence. If the target is more than 300 units away, it is recommended that you speed up your craft a bit after leaving the COI
Step Two: Traveling
Once you have completed you departure burn, immediately turn your craft retrograde (opposite to the direction you are traveling. Complete any correction maneuvers on the way. Once you are about 70 units away (within 300 units) or 90 (more than 300) Start burning and time it so that you come to a complete stop near to your target. You will usually need to fire the thrusters once to become completely still.
Step 3: Docking
Once you are still and near your target, move into alignment with your target docking node. Remember to chose one that has enough clearance around it to dock and is not obstructed. Slowly move forward and dock with your target. You are now ready to open the hatch and transfer you cargo* or crew** !
*There are some situations where docking isn't necessary to transfer cargo*
**Crew have not been added to the game as of 1.8.9. But are planned to be added at some point in the future**