A codec is a way to code (encode) and decode digital data such as a video file. It compresses the stream to reduce file size before it is transmitted to make the video playable on devices.
The container defines the structure and content of the file which can audio or video. Some containers are limited to audio, photo or video only, or combination of audio and video.