3

I've tried multiple ways of changing the locale to en_GB and nothing seems to work.

My current docker-compose.yml

version: '3.9'

services:

  db:
    image: postgres
    restart: always
    build: 
      context: .
      dockerfile: ./Dockerfile
    ports:
      - 5432:5432
    volumes:
      - ./pg-data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      PGDATA: ${PGDATA}
      # LANG: 'en_GB.UTF-8'

  adminer:
    depends_on: 
      - db
    image: adminer
    restart: always
    ports:
      - 8080:8080
  
volumes:
  pg-data:

An official postgres image docs says to create a Dockerfile with:

FROM postgres
RUN localedef -i en_GB -c -f UTF-8 -A /usr/share/locale/locale.alias en_GB.UTF-8
ENV LANG en_GB.utf8

However this has no effect whatsoever.. Tried setting enviorment variable LC_* and LANG however this throws build error of enviorment variables being configured wrong.

Having just a Dockerfile without the enviorment variables set container builds and db is being reinitialized but while running first migration with knex the table consisting money type is still in dollars.

Robert Jamborski
  • 183
  • 2
  • 13
  • You can confirm that you have created the `Dockerfile` as indicated and **replaced** the _image_ tag on your docker-compose.yml with your newly built image? – Max Aug 30 '21 at 13:27
  • Could you explain? As what I did for every try I run docker compose down -v and rm -rf postgres named volume to start clear. Docs recommend to put Dockerfile in the root where the docker-compose.yml is. I did specified the build context as root and pointed it to a Dockerfile too. Should the image have explicitly specified version eg. postgres: 9.3 in both compose file and Dockerfile? – Robert Jamborski Aug 30 '21 at 16:33
  • You say that you have created the Dockerfile above, you should then replace the tag _image: postgres_ with the image created from the Dockerfile, or alternatively you must replace the _image_ tag with _build_ – Max Aug 30 '21 at 21:45
  • Although the documentation says otherwise, I was able to use the `LANG` line in an **Alpine** based image after adding `RUN apk add --no-cache musl-locales musl-locales-lang` in the dockerfile. I’m not sure if it’s complete, but maybe this works for you too? – Martin Oct 18 '21 at 18:02

0 Answers0