Regenbogen ("Rainbow") was the code name for the planned mass scuttling of the German U-boat fleet, to avoid surrender, at the end of World War II.
At the beginning of May 1945 Nazi Germany was collapsing under the Allied onslaught.
The Soviets had captured Berlin, and on 30 April Hitler had committed suicide. He had appointed Grand Admiral Karl Dönitz as Head of State and Supreme Commander of the Armed Forces. US Forces from the west and Soviet forces from the east had already met at Torgau, cutting the Reich in two, while in the north 21st Army Group was poised to capture Hamburg and the other German ports.
The state of the German navy, the Kriegsmarine, was no better. Of its capital ships only Prinz Eugen survived, sheltering at Copenhagen; only the U-Boat Arm was capable of continuing the fight. The Kriegsmarine had approximately 470 U-boats remaining. Some 170 of these were operational U-boats (Front boats), based mainly in occupied Norway, and another 200 home-based boats in various stages of building, commissioning and working up; these were mainly in the north German ports and on the Baltic.
As head of the Kriegsmarine, and as commander of the U-boat arm, Dönitz was keen that his U-boat force should not be surrendered. However, as the new German leader, he was keen to extricate Germany from the war and, if possible, avoid Allied, particularly Soviet, retribution. To that end he had opened negotiations with the western Allies, through Field Marshal Montgomery commander of Allied 21 Army Group, in North Germany.