The relative translational and rotational dynamic models were established to meet the requirement of spacecraft high-precision formation flight. Relative attitudes of master-slave spacecraft were expressed by multiplication cross and the error dynamic equations were set up, on which nonlinear dynamic model of 6 DOF (Degree of Freedom) was proposed. Based on this model, a sliding mode controller was developed to make the translational and rotation of spacecraft correctly track the desired state trajectory and the system was showed as uniform asymptotic stability by Lyapunov theory. Simulation results indicated that the designed controller can guarantee the closed loop system to be uniform asymptotic convergence (UAC). The proposed model and the controller provide a useful theoretical reference for spacecraft formation applications of on orbit service etc.