Docker namespaces and cgroups

I know that docker is using concepts of namespaces and cgroups to isolate the process. can anyone explain thw working of namespace and cgroups in docker