I have the following Azure Devops pipeline definition that utilizes Postgres as a service container.
resources:
containers:
- container: 'postgres'
image: 'postgres:14'
ports:
- 5432:5432
env:
- POSTGRES_USER: '....'
- POSTGRES_PASSWORD: '....'
- POSTGRES_DB: '.....'
stages:
- stage: 'test'
jobs:
- job: 'test'
services:
postgres: postgres
pool:
vmImage: 'ubuntu-latest'
steps:
....
I am trying to find a way to manipulate the timezone
configuration option of the "postgres" executable that the image runs. The Postgres Docker image documentation (in the section "Database configuration") has an example of docker run
and the use of the '-c' option. Unfortunately Azure Devops seens to use docker create
and docker start
which have a slightly different syntax.
I have attempted the following already:
Using the options
setting under resources.containers.container
; this doesn't work. The value of the setting gets placed into the docker create
before the image and tag, and hence it errors out since Docker does not understand a switch like -c timezone=utc
.
Using 'Docker@2' as a step, and starting it manually; this didn't work either. The timezone
got injected to the proper place in docker start b0...e5d --timezone=utc
but the step errored out, stating "unknown flag: --timezone". The error seems to come from Docker, and not the postgres
executable itself. Apparently docker start
does not support providing arguments to the ENTRYPOINT stanza.
I have the following Azure Devops pipeline definition that utilizes Postgres as a service container.
resources:
containers:
- container: 'postgres'
image: 'postgres:14'
ports:
- 5432:5432
env:
- POSTGRES_USER: '....'
- POSTGRES_PASSWORD: '....'
- POSTGRES_DB: '.....'
stages:
- stage: 'test'
jobs:
- job: 'test'
services:
postgres: postgres
pool:
vmImage: 'ubuntu-latest'
steps:
....
I am trying to find a way to manipulate the timezone
configuration option of the "postgres" executable that the image runs. The Postgres Docker image documentation (in the section "Database configuration") has an example of docker run
and the use of the '-c' option. Unfortunately Azure Devops seens to use docker create
and docker start
which have a slightly different syntax.
I have attempted the following already:
Using the options
setting under resources.containers.container
; this doesn't work. The value of the setting gets placed into the docker create
before the image and tag, and hence it errors out since Docker does not understand a switch like -c timezone=utc
.
Using 'Docker@2' as a step, and starting it manually; this didn't work either. The timezone
got injected to the proper place in docker start b0...e5d --timezone=utc
but the step errored out, stating "unknown flag: --timezone". The error seems to come from Docker, and not the postgres
executable itself. Apparently docker start
does not support providing arguments to the ENTRYPOINT stanza.
Yes, by design, Service containers and Container jobs in Azure DevOps YAML pipelines run "docker create" command to set the startup. So, they have the same options as "docker create" command. See "Service containers - Startup options" and "Container jobs - Startup options".
However, not all of the options of "docker create" command are guaranteed to work with Azure DevOps YAML pipelines, even if the command supports the option to set time zone in the container.
So, currently, from the configuration of the pipeline, it is not possible to meet your demands when running the postgres
service container. You may need to research solutions in the Docker image, or other ways, such as the method mentioned by @Laurenz Albe
above.
ALTER SYSTEM
andSELECT pg_reload_conf()
. – Laurenz Albe Commented Jan 15 at 7:25