It is commonly labelled as "using the part for the whole" -- talking about one thing to stand for a much bigger thing of which it forms part -- although this doesn't cover the full meaning.
Examples are such things as "He hit the bottle", to mean 'He drank [the contents of the bottle]' (and note that 'hit' is a metaphor); "I like Shakespeare" for 'I like Shakespeare's plays'; or "the stage" to mean 'the acting profession' - or the whole business of the theatre. (The stage, literally, is just the platform of boards on which plays are presented.) An example of the wider meaning of using a related thing is the expression commonly heard on the news, "Downing Street said...". The street didn't say anything, but the Prime Minister (or someone else connected with government) did.
Metonymy (the abstract noun that labels this phenomenon) is so common that it can even be found as a regular convention of legal English. In the UK, criminal prosecutions are usually labelled as "The Queen vs. xxx [the accused]" ("R. v. xxx" in legal Latin). Here, the Queen - who usually knows nothing about the business, in the person of Her Majesty Elizabeth II - is a word used to mean "the system of state", or "the legal system". So it is a metonym. Even more so is the second stage of this figure of speech, where the legal profession can describe a criminal case as "The Crown vs. xxx", using the single symbolic headpiece to stand for the individual who wears it - and so, in this example, for the country's legal system.
Metonymy nowadays is commonly used to mean any figure where the name of a part is used to refer to the whole (for example, "hands" to mean workmen, or the members of the crew of a boat), or the whole for the part ("The whole weight of the law fell on him", when he was only convicted for one or two crimes). I have seen it said in textbooks of literature that all figurative language can be summarised as metaphor and metonymy. There is some truth in this (although it may be metonymous to say so!). For non-specialists, it is perhaps enough to know the names of only these two figures of speech; I would advise specialists to know many more.
The meaning of metonymy is not always precise. Sometimes the word is used to mean the same as synecdoche. In precise use by rhetoricians, one is a refinement of the other; everyone else may use them interchangeably; and even rhetoricians disagree about which is which. Another article compares the meanings of the two terms: metonymy - synecdoche.
See also Words ending -onym, -onymous, -onymy.