Codec is the short form of Compression Decompression.
So the Codecs are used to compress and decompress the information (Audio,Video, Image and Data).
Codec are used to Encode the raw data in digital format. So that this digital data can be send easily on any medium. While the medium also uses same codec to Decode the information for the playback.
Some examples- H264, MPEG4, MP3 etc.
CONTAINERS - are used to send the information from one place to another. Simply Containers contain the encoded information.
Like- MP4, AVI etc.