Search code examples
docker-machine

docker-machine time is 4 hours ahead of my macbook: container - UTC, macbook - EDT


I am running docker-machine (--driver amazonec2) on mac downloaded via homebrew. Inside the container:

date 

returns a date 4 hours ahead (UTC instead of EDT). How do I fix this? I would like the date to be the same as my local machine ie. both set to EDT. I have tried restarting docker-machine but got an error, setting environment. So far, all I have managed to do is set $TZ to new-york -however, this isn't helpful as the date still shows UTC.

RUN echo "America/New_York" > /etc/timezone

in Dockerfile and volumes

volumes:
  - "/etc/timezone:/etc/timezone:ro"
  - "/etc/localtime:/etc/localtime:ro" 

in docker-compose has not fixed the issue.


Solution

  • Instead of

    FROM node:13.12.0-alpine as build
    

    I used:

    FROM node:13.12.0 as build
    

    This is conjunction with setting

    ENV TZ America/New_York
    

    in my Dockerfile was able to solve the problem. Note: both of these modifications were necessary to solve this issue.