Well to start off you need to get the docking modules, either the docking module of the turret docking module(which allows about 70° vertical movement and 360° horizontal movement.
Once youve chosen which you want, go into build mode in a ship or use a builder block on a space station/planet/asteroid and orientate the block so it is facing outwards
Then place the docking module and you should see a red or green cube frame, if its red then there are blocks inside the docking area and these need to be removed. You now have a small dockng station.
For larger ships however (where the majority of it would be outside of the green frame, centered on the ship core) you will need to expand the area. To do so you need docking enhancers or a turret docking enhancers, depending on which docking module you used. To expand the area, while in build mode, press c to the docking module to select it and then place the enhancers anywhere on the same structure. If done correctly the enhancers should have a purple frame around them and the green frame of the docking module should be slightly larger, allowing for larger ships.