Recientemente he recibido varios mensajes de usuarios que tienen problemas para ejecutar RStudio Server con la última versión de R (4.2.2) de El proyecto rockero. La última imagen de RStudio Server se basa en r-ver:4.2.2que se basa en ubuntu:jammy
(Ubuntu 22.04). La imagen del servidor RStudio para r-ver:4.2.0 está basado en ubuntu:focal
(Ubuntu 20.04). ¿Quizás algunos usuarios tienen problemas con la última imagen de RStudio Server porque están usando un sistema operativo obsoleto y/o una versión de Docker? ¡Probemos esto!
Dos usuarios me han proporcionado sus versiones de SO y Docker.
- Ubuntu 18.04.6 y Docker versión 20.10.12
- Ubuntu 18:04.3 y Docker versión 20.10.7
Permítanme intentar replicar estos entornos utilizando una instancia de Amazon EC2. Ambos usuarios usan Bionic Beaver (Ubuntu 18.04), así que comenzaré una instancia usando este sistema operativo.
Mi versión de Ubuntu en la instancia EC2 es:
cat /etc/os-release
# NAME="Ubuntu"
# VERSION="18.04.6 LTS (Bionic Beaver)"
# ID=ubuntu
# ID_LIKE=debian
# PRETTY_NAME="Ubuntu 18.04.6 LTS"
# VERSION_ID="18.04"
# HOME_URL="https://www.ubuntu.com/"
# SUPPORT_URL="https://help.ubuntu.com/"
# BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
# PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
# VERSION_CODENAME=bionic
# UBUNTU_CODENAME=bionic
sudo apt update
Ahora buscaré el Docker correspondiente deb
archivos en el Página de descarga de Docker y utilícelo para instalar Docker.
wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce-cli_20.10.12~3-0~ubuntu-bionic_amd64.deb
sudo apt install ./docker-ce-cli_20.10.12~3-0~ubuntu-bionic_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/containerd.io_1.4.10-1_amd64.deb
sudo apt install ./containerd.io_1.4.10-1_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce_20.10.12~3-0~ubuntu-bionic_amd64.deb
sudo apt install ./docker-ce_20.10.12~3-0~ubuntu-bionic_amd64.deb
# create a docker group
sudo groupadd docker
# add the ubuntu user to the docker group
sudo usermod -aG docker ubuntu
logout
Después de volver a iniciar sesión, verifiquemos si Docker funciona.
docker --version
# Docker version 20.10.12, build e91ed57
sudo systemctl list-units --type=service | grep -i docker
# docker.service loaded active running Docker Application Container Engine
docker run hello-world
# Unable to find image 'hello-world:latest' locally
# latest: Pulling from library/hello-world
# 2db29710123e: Pull complete
# Digest: sha256:6e8b6f026e0b9c419ea0fd02d3905dd0952ad1feea67543f525c73a0a790fefb
# Status: Downloaded newer image for hello-world:latest
#
# Hello from Docker!
# This message shows that your installation appears to be working correctly.
#
# To generate this message, Docker took the following steps:
# 1. The Docker client contacted the Docker daemon.
# 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
# (amd64)
# 3. The Docker daemon created a new container from that image which runs the
# executable that produces the output you are currently reading.
# 4. The Docker daemon streamed that output to the Docker client, which sent it
# to your terminal.
#
# To try something more ambitious, you can run an Ubuntu container with:
# $ docker run -it ubuntu bash
#
# Share images, automate workflows, and more with a free # Docker ID:
# https://hub.docker.com/
#
# For more examples and ideas, visit:
# https://docs.docker.com/get-started/
Ahora que Docker está funcionando, intentemos ejecutar RStudio Server.
docker run --rm -ti -e PASSWORD=password -p 8889:8787 rocker/rstudio
# [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
# [s6-init] ensuring user provided files have correct perms...exited 0.
# [fix-attrs.d] applying ownership & permissions fixes...
# [fix-attrs.d] done.
# [cont-init.d] executing container initialization scripts...
# [cont-init.d] 01_set_env: executing...
# skipping /var/run/s6/container_environment/HOME
# skipping /var/run/s6/container_environment/PASSWORD
# skipping /var/run/s6/container_environment/RSTUDIO_VERSION
# [cont-init.d] 01_set_env: exited 0.
# [cont-init.d] 02_userconf: executing...
# [cont-init.d] 02_userconf: exited 0.
# [cont-init.d] done.
# [services.d] starting services
# TTY detected. Printing informational message about logging configuration. Logging configuration loaded from '/etc/rstudio/logging.conf'. Logging to 'syslog'.
# [services.d] done.
Ingresé rstudio/contraseña en la página de inicio de sesión.
Puedo iniciar sesión y R parece estar funcionando bien.
Ahora intentemos montar algunos directorios en el contenedor para que podamos guardar nuestro trabajo.
mkdir rmd
docker run --rm -ti -v /home/ubuntu/rmd:/home/rstudio -e PASSWORD=password -p 8889:8787 rocker/rstudio
Inicié sesión y creé un nuevo archivo RMarkdown y lo guardé en /home/rstudio. Después de detener el contenedor Docker, verifiqué el contenido de rmd
.
ls -lrt rmd
# total 4
# -rw-r--r-- 1 ubuntu ubuntu 15 Feb 24 01:03 hello.Rmd
Resumen
Inicialmente, pensé que los usuarios tenían problemas porque usaban un sistema operativo obsoleto o una versión de Docker, pero no parece ser el caso, ya que RStudio Server funcionó bien en un entorno similar.
Conseguí un Problema de GitHub con respecto a cómo solía ejecutar RStudio Server, que era usar las variables de entorno USERID y GROUPID. Esto se hizo porque los archivos creados en RStudio Server no pertenecían al usuario anfitrión.
-e USERID=$(id -u)
-e GROUPID=$(id -g)
Pero parece que el equipo de Rocker (o el equipo de Docker) ha realizado cambios, de modo que los archivos creados con RStudio Server ahora pertenecerán al usuario del host. Por lo tanto, creo que puede excluir esos parámetros a partir de ahora.
Avísame si tienes otros problemas.