Docker Community Forums

Share and learn in the Docker community.

Trying to get Postgres to work on persistent windows mount - two issues


(Teeekay) #1

Although postgres docker instance is able to create the files and database on a mounted windows directory, it complains that it can’t fsync files due to an invalid argument, and then the server does not start and it complains that the directory has the wrong ownership. I can see the files created by postgres in the intended windows directory.

the directory is owned on my windows machine by “postgres”, and sharing on c is authorized by 10.0.75.1\postgres through the docker interface.

Looking for direction on what to try next.

Information

On Windows 10 Pro. Docker Version 1.11.1-beta11 (build 2789) b0bc231

###Output from Powershell when trying to run

PS C:\users\tk\documents\DockerData\NginxData\html> docker run --name local-postgres -v c:/Users/tk/Documents/DockerData/PostgresData/pgdata:/var/lib/postgresql/data/pgdata:rw -e POSTGRES_PASSWORD=password -e PGD
ATA=/var/lib/postgresql/data/pgdata -e POSTGRES_DB=test123 postgres
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.

fixing permissions on existing directory /var/lib/postgresql/data/pgdata … ok
creating subdirectories … ok
selecting default max_connections … 100
selecting default shared_buffers … 128MB
selecting dynamic shared memory implementation … posix
creating configuration files … ok
creating template1 database in /var/lib/postgresql/data/pgdata/base/1 … ok
initializing pg_authid … ok
initializing dependencies … ok
creating system views … ok
loading system objects’ descriptions … ok
creating collations … ok
creating conversions … ok
creating dictionaries … ok
setting privileges on built-in objects … ok
creating information schema … ok
loading PL/pgSQL server-side language … ok
vacuuming database template1 … ok
copying template1 to template0 … ok
copying template1 to postgres … ok
syncing data to disk … initdb: could not fsync file “/var/lib/postgresql/data/pgdata/base/1”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/base/12374”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/base/12379”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/base”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/global”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_clog”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_commit_ts”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_dynshmem”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_logical/mappings”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_logical/snapshots”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_logical”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_multixact/members”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_multixact/offsets”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_multixact”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_notify”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_replslot”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_serial”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_snapshots”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_stat”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_stat_tmp”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_subtrans”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_tblspc”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_twophase”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_xlog/archive_status”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_xlog”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata”: Invalid argument
initdb: could not fsync file “/var/lib/postgresql/data/pgdata/pg_tblspc”: Invalid argument

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 /var/lib/postgresql/data/pgdata -l logfile start

waiting for server to start…FATAL: data directory “/var/lib/postgresql/data/pgdata” has wrong ownership
HINT: The server must be started by the user that owns the data directory.
stopped waiting
pg_ctl: could not start server
Examine the log output.

PS C:\users\tk\documents\DockerData\NginxData\html> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3041ef37856f postgres “/docker-entrypoint.s” About a minute ago Exited (1) About a minute ago local-postgres

PS C:\users\tk\documents\DockerData\NginxData\html> docker inspect postgres
[
{
“Id”: “sha256:17922730618dca1eb45b503cbff4eda600f0fc2cd5f8df10edd6b12de562710a”,
“RepoTags”: [
“postgres:latest”
],
“RepoDigests”: [],
“Parent”: “”,
“Comment”: “”,
“Created”: “2016-05-04T05:30:07.619851016Z”,
“Container”: “9ac25b9b9dddee42758d86b4ebccf172472e5b0d9fd3fe5be723638c9037df64”,
“ContainerConfig”: {
“Hostname”: “f416997e8b71”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“ExposedPorts”: {
“5432/tcp”: {}
},
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/lib/postgresql/9.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”,
“GOSU_VERSION=1.7”,
“LANG=en_US.utf8”,
“PG_MAJOR=9.5”,
“PG_VERSION=9.5.2-1.pgdg80+1”,
“PGDATA=/var/lib/postgresql/data”
],
“Cmd”: [
"/bin/sh",
"-c",
"#(nop) CMD [“postgres”]"
],
“Image”: “1ff4073b12b555b14a0fdfd913490c4cd864a66347558a55354c9c9fb24dd586”,
“Volumes”: {
"/var/lib/postgresql/data": {}
},
“WorkingDir”: “”,
“Entrypoint”: [
"/docker-entrypoint.sh"
],
“OnBuild”: [],
“Labels”: {}
},
“DockerVersion”: “1.9.1”,
“Author”: “”,
“Config”: {
“Hostname”: “f416997e8b71”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“ExposedPorts”: {
“5432/tcp”: {}
},
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/lib/postgresql/9.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”,
“GOSU_VERSION=1.7”,
“LANG=en_US.utf8”,
“PG_MAJOR=9.5”,
“PG_VERSION=9.5.2-1.pgdg80+1”,
“PGDATA=/var/lib/postgresql/data”
],
“Cmd”: [
“postgres”
],
“Image”: “1ff4073b12b555b14a0fdfd913490c4cd864a66347558a55354c9c9fb24dd586”,
“Volumes”: {
"/var/lib/postgresql/data": {}
},
“WorkingDir”: “”,
“Entrypoint”: [
"/docker-entrypoint.sh"
],
“OnBuild”: [],
“Labels”: {}
},
“Architecture”: “amd64”,
“Os”: “linux”,
“Size”: 265830314,
“VirtualSize”: 265830314,
“GraphDriver”: {
“Name”: “aufs”,
“Data”: null
},
“RootFS”: {
“Type”: “layers”,
“Layers”: [
“sha256:6eb35183d3b8bb6aee54874076fb1ad77b5259c93b330986b0cbcaa44cbbbc00”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:6a51d35aaebfe75b57e6963693cd183a302e1a1b7338be7a8277e3b6a396ea12”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:b5c933fa1001ea2dfc25ca2d2a8edcd0ea2f811c17ece6606c61c78516bed2fe”,
“sha256:a74507e68ff5848a6713f3fb8eee80e192d23da136c4bc83ae587b34494d76f5”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:9490bddf2d8874423bee92f76a73df3872e2a02e8d28a8812630aa5ae7e8f8f7”,
“sha256:e70f97cf2c0e202d7d7087839e219a92e03c93b13ef1124cc303874ea9209663”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:74f82b05066092e74a9bcbe5097f36e1ba8d4dc666447ccbd13fd6b5b9f86bf8”,
“sha256:36d2e27a27173c535de0a78a93e2be944d56cf86a6a8a26a952ba0d36b2e7eaf”,
“sha256:af5a8f47b8e2d867a7589f90092327076adc9827421d3b73e28d5b8798a5b2d7”,
“sha256:bc1f6f662d2aaae0b58ad06ec8e7a92486d9a69e5becff2dfba2b9fab002ed16”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:c51da8df7d245934aac34fd3dcc735af87f61a85a58cacc67ab0f3d4c9dd653a”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”,
“sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef”
]
}
}
]tk.dockerdebug.ps1.20160417.txt (42.9 KB)


(Cito) #2

Same problem here. I also wonder how much the database will slow down due to mounting via smb.

The answer is probably: Don’t do that. Use docker data volumes for the database files instead.


(Dendp) #3

Did you have any luck resolving this issue?


(Michael Friis) #4

As mentioned here (re: MariaDB), I think it’s unlikely that running a database with the data files mounted from a network shared NTFS filesystem can be made to work.

Out of curiosity, could you not use a non-host mapped volume for this?


(Seza443) #5

Hi

I had the same issue. But I’m using docker-compose to launch multiple containers.
The workaround I found is to create a volume with

docker volume create --name gitlab-postgresql -d local

and use this volume, instead of a host volume.

And in my docker-compose.yml looks like:

version: '2'

services:
  postgresql:
    restart: always
    image: sameersbn/postgresql:9.5-1
    volumes:
      - gitlab-postgresql-volume:/var/lib/postgresql:Z

  volumes:
    gitlab-postgresql-volume:
      external: true

Data are persistent and I have no problem of NTFS filesystem


Data directory "/var/lib/postgresql/data/pgdata" has wrong ownership
(Romaindurand) #6

Thanks ! Your solution worked perfectly for me :slight_smile:


(Somashekar) #7

Hi Friism,

Please provide me the dockerfile to create postgres on docker windows i am searching but i am unable to get the proper dockerfile.