postgresql - How to manipulate the "timezone" configuration parameter of a Postgres server running in a servic

admin2025-04-25  1

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:

  1. 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.

  2. 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:

  1. 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.

  2. 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.

Share Improve this question asked Jan 15 at 6:57 Antti KeskinenAntti Keskinen 554 bronze badges 1
  • According to this, you should be able to add an SQL script that changes the parameter with ALTER SYSTEM and SELECT pg_reload_conf(). – Laurenz Albe Commented Jan 15 at 7:25
Add a comment  | 

1 Answer 1

Reset to default 0

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.


转载请注明原文地址:http://www.anycun.com/QandA/1745596045a90951.html