2

According to here https://stackoverflow.com/a/40416306/6804200

i updated my local ubuntu jre date (os date was already true). But when i run application, date is still as old one.

I looked Application server in Docker - war deployment with IntelliJ

https://runnable.com/docker/java/dockerize-your-java-application

here but they dont do as i wanted.

I want to change jre of container which runs the app

because this

params.put("createdDate", persisted.getCreatedAt().
now(ZoneId.of(Constants.TURKEY_ZONE)).
format(DateTimeFormatter.ofPattern(Constants.DATE_TIME_FORMAT)));

brings wrong date. It is one hour before.

I need to do

java -jar tzupdater.jar -l file:///home/vegan/Downloads/tzdata2016g.tar.gz

as i do in my local.

OS is ubuntu. Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-34-generic x86_64) there are these images

jhipster/jhipster-alerter  
jhipster/jhipster-console   
jhipster/jhipster-registry   
mongo rabibtmq, 
vimagick/pure-ftpd 
and our company image about 1.8 gb.

there are around 10 12 microservices when project is app. i want to change something inside code, not starting changing start options of docker

Community
  • 1
  • 1
mark
  • 727
  • 3
  • 14
  • 35
  • 1
    after the update, did you `docker commit` the update container as a new image? See the doc https://docs.docker.com/engine/reference/commandline/commit/ – user2915097 Nov 04 '16 at 09:00
  • I did not do inside docker, i did for my local OS. not docker. docker exec -i -t ab6558034b40 /bin/bash i went inside but if i do inside, it will be for tha machine, not for image permanently. i think image mst be changed permanentyl? – mark Nov 04 '16 at 10:06
  • 1
    May be this should help - http://stackoverflow.com/questions/22800624/will-docker-container-auto-sync-time-with-the-host-machine – Rao Nov 04 '16 at 10:40
  • What is the base image are you using? And what is the os of the host operating system? – Rao Nov 04 '16 at 11:01
  • There are also a few good answers here: [Docker Container time & timezone (will not reflect changes)](http://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes) – Roman Nov 04 '16 at 13:57
  • OS is ubuntu. Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-34-generic x86_64) @Rao there are these images jhipster/jhipster-alerter jhipster/jhipster-console jhipster/jhipster-registry mongo rabibtmq, vimagick/pure-ftpd and our company image about 1.8 gb. there are around 10 12 microservices when project is app. i want to change something inside code, not starting changing start options – mark Nov 06 '16 at 12:30

2 Answers2

3
  1. You need to run tzupdater.jar inside the container(docker exec -it container_id bash and then execute the updater), because container has it's own jre.
  2. Also you need to build new docker image with updated jre that will contain latest file based time zone database(https://www.iana.org/time-zones).
  3. If it is critical for you to have accurate Timezone offsets all the time, consider using some timezone webservice. See here.
Community
  • 1
  • 1
Dennis R
  • 1,769
  • 12
  • 13
  • THere are multiple containers. ALl of them should i do for? Maybe i should check first when i exec if therei s java ? And while app is up, i can go inside container. while container is wrking, how can i kil all java to update tz? Because in my local i did in this way, killing all java – mark Nov 06 '16 at 12:33
  • 1
    If java was updated in your local machine then it probably contained timezone db update. I think you need to identify application/container that uses time zone functionality and run tzupdater in that container or upgrade java in the container. The other way is to create new container with updated java. – Dennis R Nov 07 '16 at 15:08
  • How can i identify which is that container? – mark Nov 08 '16 at 05:34
1

Can't say about docker by yes in java you can do below in some common class or in all classes where you create date object.

TimeZone.setDefault(TimeZone.getTimeZone("IST")); // IST is for timezone you want to set

Then in case of Date dt=new Date(); it will contain date as per IST timezone .

gladiator
  • 1,249
  • 8
  • 23