Instead of keeping the Postgres data folder in the container, do you know how to use a volume for this? I tried commenting out the two lines to "init-config-start-service" and "start" and then starting container with "c:\sql" mapped as a volume and then running those two commands manually. The first command works but the postgres server doesn't want to start.
Here are the commands I'm running. The last one fails because the Postgres server doesn't startup.
docker run -d -it --name pg1mustiks -p 1113:5432 -v dbmustiks:"c:/sql/" postgres-windows-mustiks powershell
docker exec -it pg1mustiks powershell c:/install/init-config-start-service "c:\sql" "postgres"
docker exec -it pg1mustiks powershell c:/install/start detached "c:\sql" "postgres"
And here is the docker file I'm using. Notice the two powershell statements are commented out near the end.
FROM microsoft/windowsservercore
# maintainer for image metadata
MAINTAINER mustiks
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV PGDATA c:\\sql
ENV PGPORT 5432
#not using PGUSER here due to need to run createuser downstream to create role
ENV PGUSERVAR postgres
ENV PGDOWNLOADVER postgresql-9.6.5-1-windows-x64-binaries.zip
# download and extract binaries
RUN wget http://get.enterprisedb.com/postgresql/$env:PGDOWNLOADVER -outfile $env:PGDOWNLOADVER ; \
expand-archive $env:PGDOWNLOADVER -force -destinationpath /postgresql ; \
rm $env:PGDOWNLOADVER
#install VC 2013 runtime required by postgresql
#use chocolatey pkg mgr to facilitate command-line installations
RUN iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
RUN choco install vcredist2013 -y
# copy dependent script(s)
COPY . /install
WORKDIR /postgresql/pgsql/bin
# init postgresql db cluster, config and create and start service
#RUN powershell /install/init-config-start-service $env:PGDATA $env:PGUSERVAR
# start postgreSQL using the designated data dir
#CMD powershell /install/start detached $env:PGDATA $env:PGUSERVAR
EXPOSE 5432
Instead of keeping the Postgres data folder in the container, do you know how to use a volume for this? I tried commenting out the two lines to "init-config-start-service" and "start" and then starting container with "c:\sql" mapped as a volume and then running those two commands manually. The first command works but the postgres server doesn't want to start.
Here are the commands I'm running. The last one fails because the Postgres server doesn't startup.
And here is the docker file I'm using. Notice the two powershell statements are commented out near the end.