Skip to content

Using Docker for Windows to volume-mount a Windows drive into a Linux container is badΒ #175

@loxy

Description

@loxy

Environment:

  • OS: Windows 10 Pro
  • docker version: 17.09.1-ce
  • docker-compose version: 1.17.1, build 6d101fb0
  • Devilbox: v0.12

When you're using Docker for Windows to volume-mount a Windows drive into a Linux container, that volume is done using a CIFS/Samba network share from the Windows host. For lots of reasons, it's highly unlikely that for example Linux Postgres will work correctly when trying to write data to a filesystem backed by NTFS shared with Samba.

So this is not working on Windows:

services:
  pgsql:
    volumes:
      # Mount PostgreSQL Data directory
      - ${HOST_PATH_PGSQL_DATADIR}/${PGSQL_SERVER}:/var/lib/postgresql/data/pgdata

You are getting:

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

Instead, use a persistent (but local to the Linux VM) named volume as detailed here: https://forums.docker.com/t/trying-to-get-postgres-to-work-on-persistent-windows-mount-two-issues/12456/5?u=friism

To summarize: The workaround is to create a (local) volume with:

$ docker volume create --name data-postgresql --driver local

And the docker-compose.yml looks something like that:

services:
  pgsql:
    volumes:
      - data-postgresql:/var/lib/postgresql

volumes:
  data-postgresql:
    external: true

The same is true for MongoDB like this issue states: #160
With this workaround everything works!

I'm not a docker expert, but maybe there's another solution instead of changing the docker-compose.yml file, which is not recommended: ## -- DO NOT EDIT THIS FILE --

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions