microsoft / microsoft/aspire

WithDataBindMount fails using PostgreSQL on Podman on Windows

Open
#14,342 3 comments 0 reactions 0 assignees View on GitHub
external podman
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

This issue seems to be described [here](https://github.com/dotnet/aspire/issues/6997), but it was closed after the author failed to respond to questions by @DamianEdwards and I cannot comment there.

My setup is:
- Aspire version 13.1.0+8a4db1775c3fbae1c602022b636299cb04971fde
- dotnet 10.0.102
- Aspire.Hosting.PostgreSQL 13.1.0
- Podman client version 5.7.1
- Podman engine (running in WSL2) version 5.7.1

In my apphost.cs, I have this:

```cs
var postgres = builder.AddPostgres("postgres");
var database = postgres.AddDatabase("mybackenddb");

if (builder.Environment.IsDevelopment()) {
postgres.WithDataBindMount("_postgres_data");
}
```

This works fine until I start the apphost. The console logs from the postgres container in the Aspire dashboard:

```
0c8880fb3d2a7abc91f0927b345395ce15ae9a1e773e13fe8d396e6a230633ef
[sys] Added new ContainerNetworkConnection: ContainerName = postgres-vmthvapu
stderr [sys] Failed to start Container: ContainerName = postgres-vmthvapu, ContainerId = 0c8880fb3d2a:
[sys] container 'postgres-vmthvapu' start failed (exit code 1)
[sys] writer is closed
[sys] not all requested objects were returned
[sys] only 0 out of 1 containers were successfully started
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

stderr chmod: changing permissions of '/var/lib/postgresql/data': Operation not permitted
stderr initdb: error: could not change permissions of directory "/var/lib/postgresql/data": Operation not permitted
fixing permissions on existing directory /var/lib/postgresql/data ...
```

The postgres container is marked "FailedToStart".

### Expected Behavior

The expected behavior is that the permissions on the bind mount would be correct, given that the directory didn't exist before starting the container. Further, an explanation of what permissions would need to be adjusted would allow me to work around the issue.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version info

.NET SDK:
Version: 10.0.102
Commit: 4452502459
Workload version: 10.0.100-manifests.73000c7b
MSBuild version: 18.0.7+445250245

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.102\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.2
Architecture: x64
Commit: 4452502459

.NET SDKs installed:
8.0.417 [C:\Program Files\dotnet\sdk]
9.0.309 [C:\Program Files\dotnet\sdk]
10.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.