Demurrage is a charge levied by the shipping line to the importer in cases where they have not taken delivery of the entire container and moved it out of the port/terminal area for unpacking within the allowed free days.
Detention is also a charge levied by the shipping line to the importer in cases where they have taken delivery of the entire container and moved it out of the port/terminal area for unpacking. Still, they have not returned the empty container to the nominated empty container depot of the shipping line.
Related article: The Secret to Understanding Sea Freight Rates