A derrick is either a crane for lifting material or a framework over an oil well that allows the drilling machinery to be raised and lowered.
A 17th century English hangman named Derrick led to a gallows being called a derrick. From there, a crane with a moveable arm came to be called a derrick because it resembled a gallows. Later, another kind of derrick was created: the kind of framework you can probably picture if you think of an oil well. That derrick allows the drilling tubes to move up and down, and all these types of derricks have a similar, up-and-down purpose.