Skip to content

Commit

Permalink
(maint) Use VOLUME in LCOW for Postgres
Browse files Browse the repository at this point in the history
 - Turns out LCOW *can* use Docker VOLUMEs with Postgres!

   As it turns out the problem was not one of bind mount vs VOLUME.
   Each LCOW VM `vmwp.exe` process (which in turn runs a single
   container) is assigned a randomized Windows user account in an
   effort to prevent VM breakout vulnerabilities.

   Unfortunately the volumes that a container owns (created in
   C:\ProgramData\Docker\volumes) are not granted full access to that
   user, which is necessary for symlink creation. So it turns out it
   *is* a permissions issue, but the problem is on the *Windows* side,
   not the Linux side!

 - For now, we can work around this problem by running the following on
   every LCOW host that we use for testing (will also update the
   Pupperware docs accordingly):

   > icacls C:\ProgramData\docker\volumes /grant *S-1-5-83-0:"(OI)(CI)F" /T

   All volumes created afterwards will inherit the `F` (FULL) permissions
   for the NT VIRTUAL MACHINE\Virtual Machines group (S-1-5-83-0).

 - This can't be done in each spec suite as the test runner agent runs a
   lower privilege account that can't change the permissions of files /
   directories within C:\ProgramData.

 - The reason this was never observed as a problem with bind mounts was
   due to ced39d7 which grants the
   directory created for the bind mount with FULL access to all Users.
   This mitigates this problem (in the original case, auto-generated
   directories under the users temp directory, don't grant permissions
   to other users - so this allows the Docker process access to the path).

 - An issue has been filed in Moby to have the vmwp.exe process user
   associated with a given container granted full access to the volume
   paths it requires:
   moby/moby#39922
  • Loading branch information
Iristyle committed Sep 16, 2019
1 parent 26f0b14 commit a5b60e0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ services:
expose:
- 5432
volumes:
# only bind mounts currently work under LCOW for Postgres
# https://github.com/moby/moby/issues/39922
- ${VOLUME_ROOT}puppetdb-postgres:/var/lib/postgresql/data
- puppetdb-postgres:/var/lib/postgresql/data
- ./postgres-custom:/docker-entrypoint-initdb.d
dns_search: ${DOMAIN:-internal}
networks:
Expand Down Expand Up @@ -82,5 +80,4 @@ volumes:
puppetserver-config:
puppetserver-data:
puppetdb-ssl:
# unused in LCOW since a bind mount is used instead - https://github.com/moby/moby/issues/39922
puppetdb-postgres:
6 changes: 0 additions & 6 deletions spec/dockerfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
describe 'The docker-compose file works' do
include Pupperware::SpecHelpers

VOLUMES = [
'puppetdb-postgres'
]

before(:all) do
# append .internal (or user domain) to ensure domain suffix for Docker DNS resolver is used
# since search domains are not appended to /etc/resolv.conf
Expand All @@ -19,8 +15,6 @@
fail "`docker-compose` must be installed and available in your PATH"
end
teardown_cluster()
# LCOW requires bind mount directories to exist
create_host_volume_targets(ENV['VOLUME_ROOT'], VOLUMES)
# ensure all containers are latest versions
docker_compose('pull --quiet', stream: STDOUT)
end
Expand Down

0 comments on commit a5b60e0

Please sign in to comment.