Skip to content

Conversation

@satrapu
Copy link
Owner

@satrapu satrapu commented Aug 11, 2023

Fix for pg_isready: FATAL: database "ContainerUser" does not exist (#4)

@satrapu
Copy link
Owner Author

satrapu commented Aug 11, 2023

Hey @mloskot, could you please test the latest tag of the Windows container on your machine?
If everything it's OK, I will publish and then merge this PR.

@satrapu
Copy link
Owner Author

satrapu commented Aug 11, 2023

Windows container seems to run correctly inside a Microsoft-hosted agent using windows-2022 VM image, as seen here.

@mloskot
Copy link

mloskot commented Aug 16, 2023

The Windows container runs indeed, on my Windows 11 too, but its log still streams the FATAL: database "ContainerUser" does not exist:

image

A possible workaround is to run it with PGUSER=postgres

image

@satrapu
Copy link
Owner Author

satrapu commented Aug 16, 2023

Hey @mloskot, I was able to replicate the initial error after setting up a Windows 11 VM; I managed to identify a way to avoid triggering the error FATAL: database "ContainerUser" does not exist.
Could you please test the latest changes once again?

Also, could you please specify the steps needed to make the volume work with the Windows container? It seems you know more than me about a working solution ...

I deliberately tried without external volume for PGDATA as that requires mounting it with auxiliary container, copying of the configuration files (not mentioned in the current README.md), then it can be mounted by this container.

Now that I have a Windows 11 VM, I could try refining my approach for building Windows container image using your tips.

@mloskot
Copy link

mloskot commented Aug 17, 2023

Hi @satrapu, I checked the latest image (db28878a0066279a7aaa7d182f062217b802897562189b2fe73bd787a5700c44) and the ContainerUser error is now gone:

$ docker run --rm -it satrapu/postgresql:latest-windows
2023-08-17 10:38:15.111 GMT [1428] LOG:  starting PostgreSQL 15.1, compiled by Visual C++ build 1914, 64-bit
2023-08-17 10:38:15.112 GMT [1428] LOG:  listening on IPv6 address "::", port 5432
2023-08-17 10:38:15.113 GMT [1428] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-08-17 10:38:15.252 GMT [1600] LOG:  database system was shut down at 2023-08-16 21:16:30 GMT
2023-08-17 10:38:15.305 GMT [1428] LOG:  database system is ready to accept connections

could you please specify the steps needed to make the volume work with the Windows container?

Here is PowerShell script which mounts two directories as volumes on the container as C:\data and C:\test mount paths:

$image = "satrapu/postgresql"
$tag = "latest-windows"
$container = ('{0}-{1}' -f $image.Replace('/', '-'), $tag)
$volumeTest = $PSScriptRoot
$volumeData = Join-Path -Path $PSScriptRoot -ChildPath 'data'
if (-not (Test-Path -Path $volumeData -PathType Container)) {
    New-Item -Path $volumeData -ItemType Directory -ErrorAction Stop
}

$dockerArgs = @('run', '-it', '--name' , $container)
$dockerArgs += '--env'
$dockerArgs += 'PGDATA=C:\data'
$dockerArgs += '--volume'
$dockerArgs += ('{0}:C:\data' -f $volumeData)
$dockerArgs += '--volume'
$dockerArgs += ('{0}:C:\test' -f $volumeTest)
$dockerArgs += ('{0}:{1}' -f $image, $tag)

Write-Host "docker $dockerArgs"
docker $dockerArgs

but the entrypoint does not seem to use the PGDATA leaving the in-container C:\data empty

image

@satrapu
Copy link
Owner Author

satrapu commented Aug 17, 2023

@mloskot, due to personal reasons I need to suspend working on this issue, but I will continue investigating it after 2 weeks or so.
Anyway, thank you for your invaluable help!

@mloskot
Copy link

mloskot commented Aug 17, 2023

No worries @satrapu take your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants