admin管理员组文章数量:1302294
So i have been trying to figure out for a week now on how to set locale inside my docker container postgres using dockerfile and so far with 0 success. The playbook itself does not fail but it also dosent do anything to resolve what the dockerfile tells it to do. Ive tried 3 different dockerfiles so far with various different ways to get it to work still all end up with same result of 0.
First dockerfile:
RUN apt-get update && apt-get install -y locales
RUN dpkg-reconfigure locales && \
locale-gen C.UTF-8 && \
/usr/sbin/update-locale LANG=C.UTF-8
RUN echo 'et_EE.UTF-8 UTF-8' >> /etc/locale.gen && \
locale-gen
ENV LC_ALL C.UTF-8
ENV LANG et_EE.UTF-8
ENV LANGUAGE et_EE.UTF-8
Second dockerfile :
FROM postgres:15.3
# Install the locales package
RUN apt-get update && \
apt-get install -y locales && \
locale-gen et_EE.UTF-8 && \
update-locale LANG=et_EE.UTF-8 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set the environment variable for the locale
ENV LANG et_EE.UTF-8
Third dockerfile:
FROM postgres:15.3
RUN localedef -i et_EE -c -f UTF-8 -A /usr/share/locale/locale.alias et_EE.UTF-8
ENV LANG et_EE.utf8
And the compose itself:
---
- hosts: all
become: yes
tasks:
- name: test docker-compose
docker_compose:
project_name: database
remove_orphans: true
definition:
version: "3.7"
services:
db_test:
image: postgres:15.3
build:
context: .
dockerfile: Dockerfile
shm_size: 1gb
#container_name: local_pgdb
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER:
POSTGRES_PASSWORD:
POSTGRES_MAX_CONNECTIONS: '400'
volumes:
- local_tst_pgdata:/var/lib/postgresql/data
db_prelive:
build:
context: .
dockerfile: Dockerfile
image: postgres:15.3
shm_size: 1gb
#container_name: local_pgdb
restart: always
ports:
- "5433:5432"
environment:
POSTGRES_USER:
POSTGRES_PASSWORD:
volumes:
- local_prelive_pgdata:/var/lib/postgresql/data
Anyone has ideas on where the mistake is, cuz after running the playbook, when i go into the container, using ssh to server hosting the docker and then docker exec to log into the container and do "locale -a" it only displays the en_US and not et_EE which i need?
To be clear, ansible output contains no info about the dockerfile, it contains the 3 lines in the dockerfile :
build:
context: .
dockerfile: Dockerfile
And that is all the informantion, even in verbose mode that it displays. Which is why i suspect it skips this step. Therefor i didnt paste that pile here. Other then rest of the compose ofc, compose itself works, the containers are created and the postgres in it is working flawlessly, its just the locale part that is defined in Dockerfile that it gives no info about, almost like it didnt see it.
So i have been trying to figure out for a week now on how to set locale inside my docker container postgres using dockerfile and so far with 0 success. The playbook itself does not fail but it also dosent do anything to resolve what the dockerfile tells it to do. Ive tried 3 different dockerfiles so far with various different ways to get it to work still all end up with same result of 0.
First dockerfile:
RUN apt-get update && apt-get install -y locales
RUN dpkg-reconfigure locales && \
locale-gen C.UTF-8 && \
/usr/sbin/update-locale LANG=C.UTF-8
RUN echo 'et_EE.UTF-8 UTF-8' >> /etc/locale.gen && \
locale-gen
ENV LC_ALL C.UTF-8
ENV LANG et_EE.UTF-8
ENV LANGUAGE et_EE.UTF-8
Second dockerfile :
FROM postgres:15.3
# Install the locales package
RUN apt-get update && \
apt-get install -y locales && \
locale-gen et_EE.UTF-8 && \
update-locale LANG=et_EE.UTF-8 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set the environment variable for the locale
ENV LANG et_EE.UTF-8
Third dockerfile:
FROM postgres:15.3
RUN localedef -i et_EE -c -f UTF-8 -A /usr/share/locale/locale.alias et_EE.UTF-8
ENV LANG et_EE.utf8
And the compose itself:
---
- hosts: all
become: yes
tasks:
- name: test docker-compose
docker_compose:
project_name: database
remove_orphans: true
definition:
version: "3.7"
services:
db_test:
image: postgres:15.3
build:
context: .
dockerfile: Dockerfile
shm_size: 1gb
#container_name: local_pgdb
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER:
POSTGRES_PASSWORD:
POSTGRES_MAX_CONNECTIONS: '400'
volumes:
- local_tst_pgdata:/var/lib/postgresql/data
db_prelive:
build:
context: .
dockerfile: Dockerfile
image: postgres:15.3
shm_size: 1gb
#container_name: local_pgdb
restart: always
ports:
- "5433:5432"
environment:
POSTGRES_USER:
POSTGRES_PASSWORD:
volumes:
- local_prelive_pgdata:/var/lib/postgresql/data
Anyone has ideas on where the mistake is, cuz after running the playbook, when i go into the container, using ssh to server hosting the docker and then docker exec to log into the container and do "locale -a" it only displays the en_US and not et_EE which i need?
To be clear, ansible output contains no info about the dockerfile, it contains the 3 lines in the dockerfile :
build:
context: .
dockerfile: Dockerfile
And that is all the informantion, even in verbose mode that it displays. Which is why i suspect it skips this step. Therefor i didnt paste that pile here. Other then rest of the compose ofc, compose itself works, the containers are created and the postgres in it is working flawlessly, its just the locale part that is defined in Dockerfile that it gives no info about, almost like it didnt see it.
Share edited Feb 10 at 14:03 Mairold Kunimägi asked Feb 10 at 13:26 Mairold KunimägiMairold Kunimägi 2131 gold badge5 silver badges12 bronze badges 4 |1 Answer
Reset to default 0So thanks to β.εηοιτ.βε in the comments, it was cleared, the error is that you cant have
image: postgres:15.3
build:
context: .
dockerfile: Dockerfile
image and build in the same compose or the image supercedes the build and therefor the build is ignored. I believe this is the mistake i have made. As of rn i dont know where the image should be, so i can not test it but im convinced this is the issue.
本文标签: Set locale in ansible managed dockercomposeStack Overflow
版权声明:本文标题:Set locale in ansible managed docker-compose - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741714897a2394050.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
build
andimage
in a compose file, theimage
instructions does take precedence, so your builds are not done. – β.εηοιτ.βε Commented Feb 10 at 17:54