Adding custom locales for Postgres when running in docker

In Ubuntu 18.04, databases are provided through sem-service and docker containers.
This poses a challenge when trying to change the locales in these services. For Postgres in particular, locales can be added by creating a Dockerfile with the following contents:

FROM postgres:9.6
RUN localedef -i fi_FI -c -f UTF-8 -A /usr/share/locale/locale.alias fi_FI.UTF-8
ENV LANG fi_FI.UTF-8

Then rebuild the postgres image using the locale:

docker build - -t postgres:lang < Dockerfile

And finally, starting the newly created image:

docker run --rm --net host -d -e POSTGRES_PASSWORD=semaphore --name postgres -v /var/run/postgresql:/var/run/postgresql postgres:lang

For other locales, fi_FI needs to be changed to the desired one, for instance, ru_RU.
It might be needed to add extra parameters to the database.yml file as well:

adapter: postgresql
encoding: utf8
ctype: ru_RU.utf8 (it was just ru_RU before)
collation: ru_RU.utf8 (it was just ru_RU before)
template: template0