-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
any plan to support native windows container postgres image #324
Comments
No current plans, but it's probably something worth considering. Looking at https://www.postgresql.org/download/windows/, we should probably use either the installers provided by EnterpriseDB (or just use the raw ZIP archives, since we don't actually need it registered as a service or anything else the installer will likely end up doing for us). |
I've played with this a little bit today, and here's my current FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
# PATH isn't actually set in the Docker image, so we have to set it from within the container
RUN $newPath = ('C:\PostgreSQL\bin;{0}' -f $env:PATH); \
Write-Host ('Updating PATH: {0}' -f $newPath); \
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine);
# doing this first to share cache across versions more aggressively
# https://www.enterprisedb.com/download-postgresql-binaries
ENV PG_VERSION 9.6.5-1
RUN $url = ('https://get.enterprisedb.com/postgresql/postgresql-{0}-windows-x64.exe' -f $env:PG_VERSION); \
Write-Host ('Downloading {0} ...' -f $url); \
Invoke-WebRequest -Uri $url -OutFile 'pgsql.exe'; \
\
Write-Host 'Extracting ...'; \
Start-Process pgsql.exe -Wait \
-ArgumentList @( \
# https://www.enterprisedb.com/docs/en/9.3/pginstguide/PostgreSQL_Installation_Guide-12.htm
'--mode', 'unattended', \
'--unattendedmodeui', 'none', \
'--extract-only', 'yes', \
'--prefix', 'C:\PostgreSQL' \
); \
\
Write-Host 'Installing ...'; \
Start-Process C:\PostgreSQL\installer\vcredist_x64.exe -Wait \
-ArgumentList @( \
'/install', \
'/passive', \
'/norestart' \
); \
\
Write-Host 'Verifying install ...'; \
Write-Host ' postgres --version'; postgres --version; \
Write-Host ' psql --version'; psql --version; \
\
Write-Host 'Removing ...'; \
Remove-Item @( \
'C:\PostgreSQL\StackBuilder', \
'C:\PostgreSQL\doc', \
'C:\PostgreSQL\include', \
'C:\PostgreSQL\installer', \
'C:\PostgreSQL\pgAdmin*', \
'pgsql.exe' \
) -Recurse -Force; \
\
Write-Host 'Complete.';
# if this is a volume, "initdb" can't change the permissions of it in the way it needs to
#ENV PGDATA C:\\pgdata ??
#VOLUME $PGDATA
# TODO docker-entrypoint.ps1 ? (for initdb and "docker run <image> --flag --flag --flag")
EXPOSE 5432
CMD ["postgres"] It builds successfully and I can run PostgreSQL commands (like Edit: note to self -- I ended up using the installer instead of the zip file because the installer includes the necessary (If we can get it working, my current plan for |
I played around with the creation of a PostgreSQL container based on the windowsservercore image as well. I built it using the installer by EnterpriseDB from the start, installed it as a service and used the old Wait-Service script to keep the container up and running referenced in this IIS container issue microsoft/iis-docker#1 (they moved to a custom service monitor for this but the script works fine for dev purposes). I ran into the same problems using volumes - even manually it is almost impossible changing the NTFS permissions in a way that the initdb process exits with success. I tried to force the container to run as another user than containeradministrator but it seems that the USER statement in windows container dockerfiles still doesn't work as one would suspect (at least I am not able to use it correclty it seems). There seems to be an option to run a container as "NT AUTHORITY\SYSTEM" and volumes as well as subfolders created in them at least appear to give this user full access by default - I've yet not managed to test this out successfully. Here is the link to the gist of the WIP Dockerfile if this is any help https://gist.github.com/WalternativE/b2c4ed32894f427ef8a85e921cfa2bbd . |
I tried the postgres ZIP file today and downloaded the Visual C++ 2013 Redistributable Package from Microsoft: The binaries seem to work both in windowsservercore and nanoserver, but I only tried the |
Hi, FROM microsoft/windowsservercore:10.0.14393.1944 AS download SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] ENV PG_VERSION 10.1-3 RUN Invoke-WebRequest $('https://get.enterprisedb.com/postgresql/postgresql-{0}-windows-x64-binaries.zip' -f $env:PG_VERSION) -OutFile 'postgres.zip' -UseBasicParsing ; RUN Invoke-WebRequest 'http://download.microsoft.com/download/0/5/6/056DCDA9-D667-4E27-8001-8A0C6971D6B1/vcredist_x64.exe' -OutFile vcredist_x64.exe ; FROM microsoft/nanoserver:10.0.14393.1944 COPY --from=download /pgsql /pgsql RUN setx /M PATH "C:\pgsql\bin;%PATH%" EXPOSE 5432 But the container is not starting |
See #506 for an approach which uses BigSQL and multi-stage builds to create something based on Nano Server that's not acceptable for the constraints of an official image, but may be useful/interesting to other folks following this thread. 👍 |
We managed to get a PostgreSQL 9.6 server working in a container on Windows using the following Dockerfile: https://gist.github.com/peetw/10f49281423753d068f62bf47ba4642f This can then be built and run with the following commands:
You can then connect to it as normal from the host running the container, i.e.:
|
Hi i am a docker noob but here's my version of creating a docker postgres windows container. Is using chocolaty cheesy? Although i might want to lock in the version. Currently they only have postgres 10.4
This is the entry-point script - i guess it could do more things
edit: I found this repo https://hub.docker.com/r/kiazhi/nanoserver.postgresql |
No description provided.
The text was updated successfully, but these errors were encountered: