The easiest way is to define a rotation based on the cube, than Slerp the capsule to this rotation (the same can be done to position the capsule) - kind of:
var target: Transform; // drag the cube here
var offSet: Vector3(0,5,0); // distance to stop
var dock = false; // set this to true to start docking
function Update(){
if (dock){
var pos = target.position + target.TransformPoint(offSet);
var rot = target.rotation;
rot = rot * Quaternion.Euler(0,0,90); // see note
transform.rotation = Quaternion.Slerp(transform.rotation, rot, Time.deltaTime);
transform.position = Vector3.Lerp(transform.position, pos, Time.deltaTime);
}
}
NOTE: Set the Euler angles above to define the relative orientation of the capsule (it depends on the cube axes).