I'm using Docker Compose to run my stack in my dev environment, but I'm having issues with the timezone in the container being one hour behind my own timezone, breaking mission-critical things and making development very difficult.
I figured this would be a common issue, so I've searched far and wide, but the only two solutions I've found don't work (don't work: no effect).
I've tried two things:
Attempt 1 - symlinking volumes from the host
By attempting to mount /etc/timezone and /etc/localtime as ro-volumes, I was hoping the container would have the same timezone as the host. No effect.
Attempt 2 - setting the variables in the command
Instead of letting Docker Compose use the ENTRYPOINT specified in my Dockerfile, I set up the command in the docker-compose.yml-file thus:
environment:
- APPLICATION_ENV=dev-docker
- TZ=Europe/Stockholm
build: ../../core/document
command: >
sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime &&
echo $TZ > /etc/timezone &&
exec /go/bin/documents"
Again, no effect at all.
Is there no official way of setting the timezone in Docker containers? I feel this should be a critical issue to more users than me.
Thanks.
Edit: the dockerfile from the core/documents-project, as requested.
# This file is intended for use with the GitLab CI tool where the binary has already been built.
FROM golang:1.9.2
# The binary is built and downloaded to the current directory by GitLab CI.
COPY ./documents /go/bin
# Run the program.
ENTRYPOINT /go/bin/documents