rocker-org / rocker-versioned

Run current & prior versions of R using docker
https://hub.docker.com/r/rocker/r-ver
GNU General Public License v2.0
297 stars 169 forks source link

System has not been booted with systemd as init system (PID 1) #242

Closed radiocontrolled closed 4 years ago

radiocontrolled commented 4 years ago

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

subprocess.call("/usr/local/bin/Rscript --vanilla myscript.R")

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:


FROM rocker/verse:3.6.0
ENV DEBIAN_FRONTEND noninteractive

# Install needed R packages
RUN install2.r --error \
    magick 

RUN install2.r --error \
    ggpubr 

RUN install2.r --error \
    extrafont

RUN install2.r --error \
    gridExtra

RUN install2.r --error \
    purrr

RUN install2.r --error \
    lubridate

RUN install2.r --error \
    jsonlite

# Install Python
RUN echo "deb http://ftp.de.debian.org/debian testing main" >> /etc/apt/sources.list
RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local
RUN apt-get update && apt-get -t testing install -y --force-yes python3.6
RUN apt-get update && apt-get -t testing install -y libmagick++-dev python3-pip python-setuptools```

Thanks
eddelbuettel commented 4 years ago

You have a number of ways:

  1. In the Dockerfile, use env TZ UTC (or choose another timezone). See rocker/r-ubuntu/focal/Dockerfile for example.
  2. You can do it system-wide via /etc/environment
  3. Ditto via /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.

radiocontrolled commented 4 years ago

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.

eddelbuettel commented 4 years ago

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.