A lock is a device for raising and lowering boats between stretches of water of different levels on river and canal waterways. The distinguishing feature of a lock is a fixed chamber whose water level can be varied; whereas in a caisson lock, a boat lift, or on a canal inclined plane, it is the chamber itself (usually then called a caisson) that rises and falls.
Locks are used to make a river more easily navigable, or to allow a canal to take a reasonably direct line across country that is not level.
The term airlock was coined for a similar device used to allow persons to pass to and from a location in which a particular atmosphere is maintained, such as underwater, in space, or in a clean room.