Cross posted from r/Docker:
I have 2 dev environments, WSL and Ubuntu Linux. I have a custom Dockerfile for Postgres that installs TimescaleDB for me. For whatever reason, the container runs perfectly fine in Ubuntu but is giving me the following errors in WSL:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
initdb: error: invalid locale settings; check LANG and LC_* environment variables
Dockerfile: ``` FROM postgres:${POSTGRES_VERSION} ARG TIMESCALE_VERSION ARG POSTGRES_VERSION ENV LC_COLLATE=en_US.UTF-8 ENV LC_CTYPE=en_US.UTF-8
COPY ./timescale.sh /docker-entrypoint-initdb.d/000-install-timescale.sh
RUN set -ex \ && apt-get update \ && apt-get install -y --no-install-recommends \ ca-certificates \ make \ cmake \ gcc \ git \ postgresql-server-dev-${POSTGRES_VERSION} \ libkrb5-dev
WORKDIR /tmp/timescaledb RUN git clone https://github.com/timescale/timescaledb . \ && git checkout ${TIMESCALE_VERSION} \ && ./bootstrap -DCMAKE_BUILD_TYPE=RelWithDebInfo -DREGRESS_CHECKS=OFF -DTAP_CHECKS=OFF -DGENERATE_DOWNGRADE_SCRIPT=ON -DWARNINGS_AS_ERRORS=OFF -DPROJECT_INSTALL_METHOD="docker"${OSS_ONLY} \ && cd build \ && make \ && make install
RUN echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | \
# tee /docker-entrypoint-initdb.d/timescaledb.sql
COPY timescale.sh /docker-entrypoint-initdb.d/timescale.sh RUN chmod x /docker-entrypoint-initdb.d/timescale.sh
WORKDIR / RUN rm -rf /tmp/timescaledb
RUN sed -r -i "s/[#]\s(shared_preload_libraries)\s=\s'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/share/postgresql/postgresql.conf.sample
RUN chown -R postgres:postgres /usr/share/postgresql && \ chown -R postgres:postgres /var/lib/postgresql && \ chown -R postgres:postgres /docker-entrypoint-initdb.d
RUN locale-gen "en_US.UTF-8"
EXPOSE 5432 ```
docker compose:
services:
postgres:
container_name: postgres
build:
context: ./postgres
dockerfile: Dockerfile
args:
TIMESCALE_VERSION: 2.10.3
POSTGRES_VERSION: 15
restart: unless-stopped
environment:
- TZ=UTC
- POSTGRES_PASSWORD
- POSTGRES_USER=root
ports:
- 5432:5432
volumes:
- postgres:/var/lib/postgresql/data
env_file:
- .env
volumes:
postgres:
Can anyone help me figure out what's going on?
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PostgreSQL/...