From c59c66087aa4b77dc4ec76c57c65582fb1344774 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Sat, 18 Apr 2026 23:10:23 +0200 Subject: [PATCH] Limit locales to 16 common languages, document how to add more Reduces locale generation from 200+ to 16 targeted locales (major world languages + Nordic + key European). Saves build time and image size. Users can add more at runtime via locale-gen. --- DOCKER_HUB.md | 13 ++++++++++++- Dockerfile | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/DOCKER_HUB.md b/DOCKER_HUB.md index 7356e02..57368df 100644 --- a/DOCKER_HUB.md +++ b/DOCKER_HUB.md @@ -125,7 +125,9 @@ The container defaults to English (`en_US.UTF-8`) and neovim as the editor. Over | `LC_ALL` | Override all locale settings | `en_US.UTF-8` | | `EDITOR` | Default text editor | `nvim` | -All common UTF-8 locales are pre-generated in the image. Example for Swedish: +Pre-generated locales: `en_US`, `en_GB`, `sv_SE`, `da_DK`, `nb_NO`, `fi_FI`, `de_DE`, `fr_FR`, `es_ES`, `it_IT`, `pt_BR`, `nl_NL`, `pl_PL`, `ja_JP`, `ko_KR`, `zh_CN` (all UTF-8). + +Example for Swedish: ```bash LANG=sv_SE.UTF-8 @@ -133,6 +135,15 @@ LANGUAGE=sv_SE:sv LC_ALL=sv_SE.UTF-8 ``` +To add a locale not in the list, run inside the container: + +```bash +sudo sed -i '/xx_XX.UTF-8/s/^# //g' /etc/locale.gen +sudo locale-gen +``` + +Replace `xx_XX` with the desired locale (e.g. `ru_RU`, `tr_TR`). This change does not persist across container restarts — for permanent additions, build from source and modify the Dockerfile. + ## Initial Setup ### 1. Create host directories diff --git a/Dockerfile b/Dockerfile index ca5a043..ae1ea27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -110,7 +110,8 @@ RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "aarch64" chmod +x /usr/local/bin/rustup-init # Set locale — generate common UTF-8 locales (override via LANG/LC_ALL env vars) -RUN sed -i '/\.UTF-8/s/^# //g' /etc/locale.gen && locale-gen +# To add more locales, run: sudo sed -i '/.UTF-8/s/^# //g' /etc/locale.gen && sudo locale-gen +RUN sed -i -E '/(en_US|en_GB|sv_SE|da_DK|nb_NO|fi_FI|de_DE|fr_FR|es_ES|it_IT|pt_BR|nl_NL|pl_PL|ja_JP|ko_KR|zh_CN)\.UTF-8/s/^# //g' /etc/locale.gen && locale-gen ENV LANG=en_US.UTF-8 ENV LANGUAGE=en_US:en ENV LC_ALL=en_US.UTF-8