A dungeon is a room or cell in which prisoners are held, especially underground. Dungeons are generally associated with medieval castles, though their association with torture probably belongs more to the Renaissance period. An oubliette or bottle dungeon is a form of dungeon which is accessible only from a hatch or hole (an angstloch) in a high ceiling.
The word dungeon comes from French donjon (also spelled dongeon), which means "keep", the main tower of a castle. The first recorded instance of the word in English was near the beginning of the 14th century when it held the same meaning as donjon. The proper original meaning of "keep" is still in use for academics, although in popular culture it has been largely misused and come to mean a cell or "oubliette". Though it is uncertain, both dungeon and donjon are thought to derive from the Middle Latin word dominio, meaning "lord" or "master".
In French, the term donjon still refers to a "keep", and the English term "dungeon" refers mostly to oubliette in French. Donjon is therefore a false friend to dungeon (although the game Dungeons & Dragons is titled Donjons et Dragons in its French editions).
An oubliette (from the French oubliette, literally "forgotten place") was a form of prison cell which was accessible only from a hatch or a hole (sometimes called an angstloch) in a high ceiling. The word comes from the same root as the French oublier, "to forget", as it was used for those prisoners the captors wished to forget. The use of "donjons" evolved over time, sometimes to include prison cells, which could explain why the meaning of "dungeon" in English evolved over time from being a prison within the tallest, most secure tower of the castle into meaning a cell, and by extension, in popular use, an oubliette or even a torture chamber.