LOG: could not open directory "/usr/share/zoneinfo": No such file or directory
which results in:
SELECT * FROM pg_timezone_names;
ERROR: could not open directory "/usr/share/zoneinfo": No such file or directory
which can be fixed with
apk add tzdata
This was actually excluded intentionally (https://github.com/docker-library/postgres/blob/03f4064a045114f56fa445eb602339faaf79eeec/Dockerfile-alpine.template#L101-L102):
# tzdata loading functionality is optional, and fails gracefully
# tzdata \
Once it's added, it cannot be removed again (for users who don't need it), and it does add ~1.288 MB to the image size.
Something like the following should work to add it after the fact (which will then be imported during docker-entrypoint.sh and available at runtime):
FROM postgres:9.6-alpine
RUN apk add --no-cache tzdata
Thanks for the explanation.
For anyone interested: there's an unofficial repo of postgres in alpine with tzdata enabled out of the box.
Is the timezone data used commonly enough that we should reconsider including it by default?
Another really simple solution would be to mount in zoneinfo from the host, ie -v /usr/share/zoneinfo:/usr/share/zoneinfo:ro
Is the timezone data used commonly enough
It sorta is. The Django documentation suggests that timezone should be set for Postgre for performance reasons.
It seems to add 1.288 MB to the image
@ptman it is around 1/50 of image size, which is not that terribly much.
Yeah, seems sane enough -- someone want to make a PR uncommenting the existing line and removing the comment it has? (probably adding a new one pointing to that Django documentation as a real-world example)
Most helpful comment
This was actually excluded intentionally (https://github.com/docker-library/postgres/blob/03f4064a045114f56fa445eb602339faaf79eeec/Dockerfile-alpine.template#L101-L102):
Once it's added, it cannot be removed again (for users who don't need it), and it does add ~1.288 MB to the image size.
Something like the following should work to add it after the fact (which will then be imported during
docker-entrypoint.shand available at runtime):