Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Add alpine pkg "tzdata" to alpine Dockerfile template #949

wants to merge 1 commit into from

Conversation

seagleNet
Copy link

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).

@tianon
Copy link
Member

tianon commented Jan 29, 2020

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 /etc/localtime from the host into the container (instead of setting TZ) will usually just do-the-expected-thing for users (setting the container's timezone to that of the host).

@J0WI
Copy link
Contributor

J0WI commented Jan 29, 2020

The Debian variant has it by default.

@phy25
Copy link

phy25 commented Jan 29, 2020

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.

@tianon
Copy link
Member

tianon commented Jan 29, 2020

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).

@seagleNet
Copy link
Author

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:
https://github.com/nginxinc/docker-nginx/blob/master/mainline/alpine/Dockerfile#L101

@phy25
Copy link

phy25 commented Jan 30, 2020

@thaJeztah
Copy link
Contributor

Alpine is really fast when installing packages, so adding it to either your Dockerfile (add a RUN apk add --no-cache tzdata) or even at runtime (if you don't use a Dockerfile 🙀) would allow you to add the package if you need it;

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

@phy25
Copy link

phy25 commented Jan 30, 2020

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.

@tianon
Copy link
Member

tianon commented Jun 25, 2020

I think docker-library/golang#250 (comment) is pretty relevant here also.

@mvorisek
Copy link
Contributor

are tzdata used actually by php?

@tianon
Copy link
Member

tianon commented Jul 1, 2021

I don't think so -- without adding tzdata, I'm able to still use date/time related functions, and they work appropriately when I change the timezone:

$ 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

@mvorisek
Copy link
Contributor

mvorisek commented Jul 4, 2021

I think this should be closed then as it is completely unrelated to php.

@tianon tianon closed this Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants