The Flying Dutchman was originally just a regular ship. In 1641, off the coast of Africa, an experimental time ship from the 47th century crashed into the Dutchman, destroying the ship and killing all of the crew. The robots that manned the time ship fixed their ship by merging it with the Flying Dutchman. They malfunctioned and believed themselves to be the original crew. They travelled across Earth through both space and time, but they couldn't make port anywhere because of the ship's 47th century technology.
During the time he spent alone after the death of Clara Oswald, the Twelfth Doctor began tracking down the ship. After following the ship for some time, the Doctor created a mathematical equation to accurately determine where the ship would go next.
He followed the ship to the coast of Australia in 1881, where the Dutchman appeared near a ship carrying Prince George. Taking George and the ship's captain with him, the Doctor followed the Dutchman to the Gulf of Mexico in 2068. The Dutchman then went to the Battle of Trafalgar, where the Doctor, George, and Thorpe managed to jump onto it.
They were attacked by the robots that ran the Dutchman. As the Doctor was forced to walk the plank, George took control of the ship and took it to the coast of Africa in 1641. The robots saw their ship crash into the original Flying Dutchman and realised that they were not the original crew. The Doctor used his sonic screwdriver to completely fix the time ship, allowing it to visit the 47th century. The Doctor used the ship to return to his TARDIS and programmed the ship to return to the 47th century with a note saying that their time travel experiment failed. (COMIC: Ghosts of the Seas)
The Seventh Doctor created an electronic avatar called the Flying Dutchman, who contacted FLORANCE and BAR B in the 30th century to obtain a list of mental patients with a specific type of pathology. (PROSE: So Vile a Sin)