-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add alpine pkg "tzdata" to alpine Dockerfile template #949
Conversation
It's a fairly small amount of added space, but I'm not convinced it's relevant for us to add -- many users likely don't care about timezone data (and even though small, it becomes unremovable if we add it here), and for the rest, bind-mounting |
The Debian variant has it by default. |
debian's tzdata is installed by upstream, not by this Dockerfile, while alpine is as clean as possible by default. $ docker run -it --rm debian apt list --installed | grep tzdata
tzdata/now 2019c-0+deb10u1 all [installed,local] I think debian and alpine varients have different directions towards what to have/what not to have. As @tianon mentioned, the size of the image will increase once tzdata is installed, which cannot be avoided by end users, and I believe a lot of users are not expecting this. |
Indeed, in my mind the main difference is that the Alpine variants are all explicitly focused on minimal size (it's the main compelling argument to using Alpine in the first place). |
While I agree about Alpine's main appeal being the minimal size, but we're talking about 3MB here. Is that really that big of a deal? Also from what I've learned it should be avoided as much as possible mounting volumes/files into your container and instead use environment variables where possible. I saw that nginx installs tzdata by default in their Alpine image: |
Some references: |
Alpine is really fast when installing packages, so adding it to either your Dockerfile (add a Looks like it takes less than a second to install; docker run --rm php:alpine sh -c 'time apk add --no-cache tzdata && exec php -a'
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/1) Installing tzdata (2019c-r0)
Executing busybox-1.31.1-r9.trigger
OK: 23 MiB in 33 packages
real 0m 0.53s
user 0m 0.09s
sys 0m 0.06s
Interactive shell |
Honestly if every image adds tzdata, 2MB will become a lot. I am not sure if this should be a baseline of alpine or something else - Apache here I believe only uses it for logging as Redis does. |
I think docker-library/golang#250 (comment) is pretty relevant here also. |
are tzdata used actually by php? |
I don't think so -- without adding $ docker pull php:alpine
alpine: Pulling from library/php
Digest: sha256:edd37734c824c65cdbc1e68c9ac928c590a5c750b6b49c656a302b3b0742d371
Status: Image is up to date for php:alpine
docker.io/library/php:alpine
$ docker run -it --rm php:alpine
Interactive shell
php > echo date(DATE_RFC2822);
Thu, 01 Jul 2021 18:39:48 +0000
php > date_default_timezone_set('America/Los_Angeles');
php > echo date(DATE_RFC2822);
Thu, 01 Jul 2021 11:40:02 -0700 |
I think this should be closed then as it is completely unrelated to php. |
With the package "tzdata" installed on the alpine image it's easily possible to set the container's timezone by setting TZ environment variable (e.g. TZ=Europe/Zurich).