Memory dump with Nano server and Docker

In this post I will detail the steps to create a memory dump for an application which runs in a docker container on Windows Nano server.

Here, I would like to thank @gaborpro for his suggestions throughout the process.

Let's assume we have a .net core application being developed, the application will run in a container based on an image with Windows Nano. At some point we will need to create a memory dump of our application to investigate performance issues. To get started a tool (an exe) needs to be available in the container for creating the dump file. There are several ways to achieve this:

  1. Include the tool along with the application (COPY it in the dockerfile)

  2. Extend the base image

  3. Use docker cp command to copy it (if the command is supported on your platform)

  4. Map an external drive (as a volume) with the tool available on the drive

To create the dump file, the procdump tool will be used. It has a Windows Nano server version available, you can download it with the Sysinternals tool Sysinternals suite for Nano Server.

Unfortunately, using the regular procdump.exe will show no errors, but simply won't create the dump for us.

Open an interactive powershell (or cmd) on the container with docker exec -it [containerName] powershell and lists processes with the 'Get-Process' command.

This will show your dotnet process and its Process ID. All we left to do is create the memory dump, navigate to the procdump exe and run: .\procdump64.exe -ma [PID]. Use -accepteula option on the first use, to accept the end use license agreement.

The generated dump file can be moved back to the host machine for analysis. As earlier described, we can do it through the mounted volume or docker cp command. Once it is available, we can use PerfView - among many other tools - to investigate the dump file.

The actual memory dump investigation is out of the scope of this post as the investigation depends on the type of memory issue the application has. There are several great courses and tutorials in this topic available on the web.