Closed radiocontrolled closed 4 years ago
You have a number of ways:
Dockerfile
, use env TZ UTC
(or choose another timezone). See rocker/r-ubuntu/focal/Dockerfile for example./etc/environment
/etc/profile
or /etc/bash.bashrc
or their per-user equivalents.Also, you can make you Dockerfile
more readable and lighter via grouping the install2.r
commands in one RUN
, and same with your apt-get install
. Also no need to call update twice.
Thanks @eddelbuettel. Using env TZ UTC
allowed me to run the container on my local machine and I didn't have the error I saw before. I then ran it in ECS (Fargate) and it worked.
It's actually an old issue but R recently moved code around and when TZ
is not set, will call timedatectl
"because just about every systemd using system these days has it". But containers run subsets of a real machine, are not spawned by systemd and have no timedatectl. Bang. Hence the avoidance by setting TZ.
I am having this error with an R script getting killed on "System has not been booted with systemd as init system (PID 1). Can't operate." I run this script within a docker container on ECS. A python subprocess calls the Rscript, eg
Usually this works fine but lately it is not working. I have read this is about not setting the
TZ
environment variable. But I don't know how to set this variable. Is there an example of how to do this in a Dockerfile? Or in an Rscript? (the R script uses Lubridate if that helps)https://github.com/rocker-org/rocker-versioned/issues/89
This is my base dockerfile: