Skip to content
This repository was archived by the owner on Dec 14, 2019. It is now read-only.

could not open file "C:\.pgpass" for reading: No such file or directory #2

Open
fzumstein opened this issue Nov 6, 2019 · 6 comments

Comments

@fzumstein
Copy link

I am on Windows Server 2019 with LCOW. When I leave away the password, the docker container comes up correctly:

docker run --name some-postgres -d stellirin/postgres-windows

However, when I include the password, then I get the following error, any ideas?

docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d stellirin/postgres-windows

Error:

$ docker logs some-postgres
Access is denied.
The files belonging to this database system will be owned by user "ContainerUser".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.
initdb: could not open file "C:\.pgpass" for reading: No such file or directory
authMethod: md5
The system cannot find the drive specified.
PostgreSQL init process complete; ready for start up.
@stellirin
Copy link
Owner

Oof it's been over a year since I wrote this and I'm not exactly an expert at Windows CMD!

The relevant code is at: https://github.com/stellirin/docker-postgres-windows/blob/master/docker-entrypoint.cmd#L67

The file is required because the equivalent code in the original docker-entrypoint.sh uses features of UNIX shell not available to CMD. See: https://github.com/docker-library/postgres/blob/master/12/docker-entrypoint.sh#L75

The behaviour you see suggests that the --pwfile="C:\.pgpass" is correctly set but the echo command to create the file is not working. It definitely worked in the past as I tested this locally and the software I use at work was able to connect to the database.

C:\.pgpass might not be the best location for this file, is it possible some permissions in the Windows container environment got tightened up?

I'll try to take a look this weekend.

@fzumstein
Copy link
Author

Thanks for your response! In the meantime I could make the original Linux based image work by using this hack: https://github.com/puppetlabs/pupperware/blob/master/README-windows.md#set-the-volumes-directory-permissions together with a named volume (host mounting wouldnt work). So feel free to close this issue.

@stellirin
Copy link
Owner

Glad you found a solution that works for you! I'll probably take a look anyway as I'm behind the latest releases. But most of my motivations for this image have disappeared since the release of Docker for WSL2.

@fzumstein
Copy link
Author

fzumstein commented Nov 7, 2019 via email

@stellirin
Copy link
Owner

So I updated the images and ran a quick test of v12 and all works OK here on the latest Windows 10 Pro.

Right now I can only imagine that your issue is caused by stricter permissions on Windows Server 2019.

I guess I could look at moving this file to the TEMP folder? There's no real reason for this to be written as C:\.pgpass

The files belonging to this database system will be owned by user "ContainerUser".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory C:/pgsql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... windows
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Belgrade
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
ok


Success. You can now start the database server using:

    pg_ctl -D ^"C^:^\pgsql^\data^" -l logfile start

authMethod: md5
The system cannot find the drive specified.
waiting for server to start.... done
server started
CREATE DATABASE
waiting for server to shut down.... done
server stopped
PostgreSQL init process complete; ready for start up.

@fzumstein
Copy link
Author

OK, that's possible. Also possible that there's a difference between Docker EE and Docker Desktop (which I assume you use).

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants