How can I completely record and replay a VM/Docker instance?

Let’s say I have a program which is not open source, or I want to exactly reproduce the result of previously executed program. It may have Web-calls or may lookup the system time or access any resource dynamically. Is there any tool that can record all the computations of a Docker container or virtual machine instance and repeat it later (this means mocking all the dynamic resources again)?