B
B
Bogdan2018-04-26 14:54:49
PostgreSQL
Bogdan, 2018-04-26 14:54:49

Postges mount to local folder on Windows?

I am using Windows 10 x64. Tell me please.
If you specify a local folder for mounting, then the following error occurs.
docker-compose.yml

version: '3.6'
services:
  db:
    image: postgres:10.3
    ports:
      - "5432:5432"
    volumes:    
      - ./postgres:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: postgres

mistake
spoiler
PS D:\ProjectRuby\RailsDocker> docker-compose up
Creating network "railsdocker_default" with the default driver
Creating railsdocker_db_1 ... done
Attaching to railsdocker_db_1
db_1  | The files belonging to this database system will be owned by user "postgres".
db_1  | This user must also own the server process.
db_1  |
db_1  | The database cluster will be initialized with locale "en_US.utf8".
db_1  | The default database encoding has accordingly been set to "UTF8".
db_1  | The default text search configuration will be set to "english".
db_1  |
db_1  | Data page checksums are disabled.
db_1  |
db_1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
db_1  | creating subdirectories ... ok
db_1  | selecting default max_connections ... 100
db_1  | selecting default shared_buffers ... 128MB
db_1  | selecting dynamic shared memory implementation ... posix
db_1  | creating configuration files ... ok
db_1  | running bootstrap script ... ok
db_1  | performing post-bootstrap initialization ... ok
db_1  | syncing data to disk ... initdb: could not fsync file "/var/lib/postgresql/data/base/1": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/base/12993": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/base/12994": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/base": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/global": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_commit_ts": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_dynshmem": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_logical/mappings": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_logical/snapshots": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_logical": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact/members": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact/offsets": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_notify": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_replslot": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_serial": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_snapshots": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_stat": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_stat_tmp": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_subtrans": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_tblspc": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_twophase": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_wal/archive_status": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_wal": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_xact": Invalid argument
db_1  | initdb: could not fsync file "/var/lib/postgresql/data": Invalid argument
db_1  | ok
db_1  |
db_1  | Success. You can now start the database server using:
db_1  |
db_1  |     pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1  |
db_1  | initdb: could not fsync file "/var/lib/postgresql/data/pg_tblspc": Invalid argument
db_1  |
db_1  | WARNING: enabling "trust" authentication for local connections
db_1  | You can change this by editing pg_hba.conf or using the option -A, or
db_1  | --auth-local and --auth-host, the next time you run initdb.
db_1  | waiting for server to start....2018-04-26 11:47:52.383 UTC [36] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
db_1  | 2018-04-26 11:47:52.383 UTC [36] HINT:  The server must be started by the user that owns the data directory.
db_1  |  stopped waiting
db_1  | pg_ctl: could not start server
db_1  | Examine the log output.
railsdocker_db_1 exited with code 1


Creates files in a folder.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hikmat Abdunabiev, 2018-04-26
@Khikmat

This is a known limitation in Docker for Windows. The semantics of mapping a filesystem from a Windows directory to a Linux directory is not perfect because the mount is done using CIFS/SMB. One of the things that won't work is chown (change ownership) in the Windows file system.
You should probably use a named volume. This forum post has details: https://forums.docker.com/t/data-directory-var-lib...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question