(covers information from several alternate timelines)
A spacedock, or drydock, was a facility where starships were loaded, unloaded, built, or repaired. Most spacefaring species had some type of spacedock, and they thus varied widely in design. The United Federation of Planets and United Earth had spacedocks that most often took the form of a free-standing, orbital, single-starship-sized "cage". This form of spacedock was virtually synonymous with the word drydock. Generally, these cage designs were used for major construction or refits and could be part of a shipyard.
Some spacedocks, however, were part of starbases and outposts, and allowed for more secure repairs in a totally enclosed, multi-functional facility. The USS Excelsior enjoyed at least the final stages of its construction in such a facility orbiting Earth.
In the mirror universe year 2155, the Tholians took the USS Defiant to a spacedock built into an asteroid-moon in orbit around a gas giant and began a salvage operation, but were unable to finish because the ship was stolen by Commander Jonathan Archer of the ISS Enterprise. (ENT: "In a Mirror, Darkly")
Following the Battle near Xahea, the Enterprise spent a hundred and twenty four days in Drydock undergoing repairs until it was finally restored to active status in 2258. (DIS: "Such Sweet Sorrow, Part 2")
In 2259 of the alternate reality, a facility affiliated with Section 31 was in orbit of the Jovian moon Io. Known as the Io Facility, it was where the USS Vengeance was constructed and launched. (Star Trek Into Darkness) In 2263, the USS Enterprise-A was under construction in a spacedock located in one of the space lanes of Yorktown Station. (Star Trek Beyond)
In 2371, all of Earth's spacedocks were erased from existence after the death of Gabriel Bell in 2024. They, and the correct timeline, were restored after Benjamin Sisko assumed Bell's identity and successfully brought the Bell Riots to their original conclusion. (DS9: "Past Tense, Part I", "Past Tense, Part II")
Also in that year, Chief Miles O'Brien told Captain Sisko that a spacedock would be a better place to repair the USS Defiant than Deep Space 9 after Michael Eddington's cascade virus damaged the ship. (DS9: "For the Uniform")
There were also spacedocks in orbit of Trelka V in the 2370s. Three Galor-class starships were docked there in 2375 when Martok led the attack on the Trelka starbase. (DS9: "Once More Unto the Breach")
The first mention of a spacedock is in "The Doomsday Machine".
The script for The Motion Picture calls the structure an "Orbital Dry Dock".
The terms "Spacedock" and "Drydock" have been used interchangeably to describe the same structures. NAR-30974, the facility the USS Enterprise-B was launched from in Star Trek Generations, had markings saying it was a "Starfleet Drydock" while the script and dialogue used "spacedock." Voyager launched from a similar, if smaller, facility that was referred to as a "drydock" in dialogue and the scripts in the episode "Relativity".
Very little is known about the enclosed spacedocks seen in the Star Trek films and TNG episodes. Their dimensions, internal layout, regular and maximum compliment, and if the spacedock was open to civilians or if it was restricted to Starfleet personnel, is unknown.
There seem to be very different sizes of the enclosed spacedocks, despite having the same basic "mushroom" design in the 23rd century as they do in the 24th. It is known, for instance, that some can accommodate a Galaxy-class starship, although the facility seen in the movies – whose space doors seem barely wide enough to accommodate the Enterprise – seem able to admit nothing larger than an Excelsior-class vessel. This is because stock footage of the original Enterprise entering the dock was superimposed with the new, larger USS Enterprise-D entering the same port.