Skip to content

PgAdmin doesn't work in WSL or devcontainers #4889

@aaronpowell

Description

@aaronpowell

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a project which I want to use PostgreSQL as the database and use PgAdmin. For this project, I primarily develop in a devcontainer, but have verified that this problem also exists when running on WSL.

When the PgAdmin container starts up, it reports the following in the logs:

Error reading input file /pgadmin4/servers.json: [13] Permission denied

If I look at the file it is mapped to on the host (the file in /tmp), the permissions are as follows:

> ls --color=tty -la /tmp/tmpbeobg8.tmp
-rw------- 1 aaron aaron 224 Jul 15 11:42 /tmp/tmpbeobg8.tmp

These permissions are reflected when inspecting the mounted file in the container.

Here's the mount definition in the container config:

        {
            "Type": "bind",
            "Source": "/tmp/tmpbeobg8.tmp",
            "Destination": "/pgadmin4/servers.json",
            "Mode": "",
            "RW": true,
            "Propagation": "rprivate"
        },

Here's the contents of the temp file:

{"Servers":{"1":{"Name":"pg","Group":"Servers","Host":"host.docker.internal","Port":37429,"Username":"postgres","SSLMode":"prefer","MaintenanceDB":"postgres","PasswordExecCommand":"echo \u0027naB15rzq((4}-~PgKt2Dv}\u0027"}}}

The result of this is that no servers are listed in PgAdmin.

If I open the same codebase on Windows and run, the problem does not occur.

Expected Behavior

I would expect PgAdmin to load the same on Windows as it does in WSL/devcontainers.

Steps To Reproduce

I have provided a test repo here: https://github.com/aaronpowell/aspire-pgadmin-bug

  1. Open WSL (I used Ubuntu as the distro)
  2. Create a new .NET Aspire application: mkdir aspire-pgadmin && cd aspire-pgadmin && dotnet new aspire
  3. Add the PostgreSQL hosting package dotnet add package --project aspire-pgadmin.AppHost Aspire.Hosting.PostgreSQL
  4. Add the following code to the Program.cs in AppHost:
var pg = builder.AddPostgres("pg")
    .WithPgAdmin()
    .AddDatabase("db");
  1. Launch the Aspire application and open the PgAdmin resource web portal. Observe no servers are listed
  2. Open the logs for the PgAdmin container in the Dashboard. Observe the error reported about access denied to server.json

Exceptions (if any)

No response

.NET Version info

.NET SDK:
 Version:           8.0.301
 Commit:            1a0e9c0300
 Workload version:  8.0.300-manifests.7ccdde63
 MSBuild version:   17.10.4+10fbfbf2e

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/8.0.301/

.NET workloads installed:
 [aspire]
   Installation Source: SDK 8.0.300
   Manifest Version:    8.0.2/8.0.100
   Manifest Path:       /usr/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.0.2/WorkloadManifest.json
   Install Type:        FileBased


Host:
  Version:      8.0.7
  Architecture: x64
  Commit:       2aade6beb0

.NET SDKs installed:
  8.0.301 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.7 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.7 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationpostgresIssues related to Postgres integrations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions