---
title: "Container Environments"
description: "How to use the Sentry Native SDK in container environments."
url: https://docs.sentry.io/platforms/native/advanced-usage/container-environments/
---

# Container Environments | Sentry for Native

## [Database Path on a Mounted Volume](https://docs.sentry.io/platforms/native/advanced-usage/container-environments.md#database-path-on-a-mounted-volume)

The Sentry Native SDK uses a [database path](https://docs.sentry.io/platforms/native/configuration/options.md#database-path) to store events and crash reports. When you are using a containerized environment, you may want to mount a volume to persist the database across container restarts to avoid losing this data.

## [Waiting for `Crashpad` to Finish](https://docs.sentry.io/platforms/native/advanced-usage/container-environments.md#waiting-for-crashpad-to-finish)

Starting with SDK version [0.8.3](https://github.com/getsentry/sentry-native/releases/tag/0.8.3) for Linux and [0.9.0](https://github.com/getsentry/sentry-native/releases/tag/0.9.0) for Windows, the [option `crashpad_wait_for_upload`](https://docs.sentry.io/platforms/native/configuration/options.md#crashpad-wait-for-upload) allows the application to wait for the `crashpad_handler` to finish before a shutdown-after-crash.

In SDK versions older than `0.8.3`/`0.9.0`, you could use a script similar to the example below to tie container shutdown to the `crashpad_handler` process:

```bash
#!/bin/bash

# ./execute-main-app

crashpad_timeout_s=10
crashpad_process_name=crashpad_handler
crashpad_pid=$(pgrep -n -f $crashpad_process_name)
if [ -n "$crashpad_pid" ]; then
    echo "Waiting for crashpad to finish..."
    timeout $crashpad_timeout_s tail --pid=$crashpad_pid -f /dev/null
    if [ $? -eq 124 ]; then
        echo "The crashpad process did not finish within $crashpad_timeout_s seconds"
    else
        echo "The crashpad process finished successfully"
    fi
fi
```

on Linux, or for Windows PowerShell

```powershell
# Start-Process -FilePath ".\main-app.exe" -Wait

$crashpadTimeoutSec = 10
$crashpadProcessName = "crashpad_handler"
$crashpadProcess = Get-Process -Name $crashpadProcessName -ErrorAction SilentlyContinue | Sort-Object StartTime -Descending | Select-Object -First 1
if ($null -ne $crashpadProcess) {
    Write-Output "Waiting for crashpad to finish..."
    $finished = $crashpadProcess.WaitForExit($crashpadTimeoutSec * 1000)
    if (-not $finished) {
        Write-Output "The crashpad process did not finish within $crashpadTimeoutSec seconds"
    } else {
        Write-Output "The crashpad process finished successfully"
    }
}
```
