docker-library/php

Configure session.save_path and expose it as volume

mikehaertl opened this issue · 2 comments

Right now session.save_path is empty (default) and so the session data is stored to /tmp. This directory is not exposed as a volume. So by default we loose all sessions whenever a container is dropped and newly built. So containers aren't really "ephemeral" as they store some state information.

To avoid permission issues I think it's better to configure a directory for session.save_path, e.g. /var/php/sessions and make this available as a volume, so that it's easy to mount a host volume there.

While I agree at the high level, I don't think it's reasonable for us to make this change at the base php level -- the default configuration of PHP stores sessions in /tmp, so IMO it makes sense to stick to that. That being said, I'd love to see this documented as a container-specific concern that users of this image might be interested in fixing or working around in some way over in the documentation for the image. 👍

Thanks!

Could you provide an example of using a volume on the host so when container is rebuilt session data is persisted