Remove the battery from the rear rack.
Unplug the power plug from the port in the frame and unwrap the coils holding the wires together.
You can leave the rack installed on the bike frame. Remove the battery dock from the rear rack by removing the 4 bolts on the underside. If you are only removing the dock (leaving the battery tray) you only need to remove the 4 bolts.
Pull the dock free of the rear rack. Remove the 4 philips screws that hold the two halves together. They are accessed from the underside.
Open the dock up. If you are replacing the lock or swapping it to a new dock undo the philips screw to do so.
Lift the battery prongs up and out of the slot that they sit in. Pull the wire out through the hole.
On the new battery dock: mount the lock and feed the power plug through the hole in the bottom. Note that the red wire/positive side is facing the lock. Slide the battery prongs into the slot in the battery dock.
Close the two halves of the battery dock and install the philips screws to hold them together.
Install the dock back onto the rack by setting it in place on top of the battery tray. There are 4 holes that the dock fits into. Install the 4 bolts from the underside of the rack.
Plug the power plug into the port on the frame and use the wire coils to manage the wiring.
Insert the rear rack battery.