如何在Alpine中安装R 3.4.4 [英] How to install R 3.4.4 in alpine
问题描述
我正在尝试在我的docker高山映像中安装R.之前我确实使用
I am trying to install R in my alpine image of docker. Earlier I did install it in my ubuntu image using
运行apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 \&&add-apt-repository'deb [arch = amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'\&&apt-get update \&&&apt-get install -y r-base
在任何地方我都找不到如何在高山中安装它.任何帮助将不胜感激.
Nowhere I could find how to install it in alpine. Any help would be appreciated.
我的基本映像是python:3.7-alpine
My base image is python:3.7-alpine
推荐答案
R is available in Alpine community repositories, so it's just a matter of installing the proper package:
apk加R
对于更紧凑的图像,如果您不需要专门的Python,则可以从原始的Alpine图像开始,例如 alpine:3.9
.
For a more compact image you could start off a vanilla Alpine image, such as alpine:3.9
, if you don't need Python specifically.
Alpine上可用的最新R版本是3.5.1.最接近3.4.4的是3.4.2,该版本在Alpine V3.7中可用.在这种情况下,请启动Alpine V3.7:
The latest R version available on Alpine is 3.5.1. The closest to 3.4.4 is 3.4.2, which is available in Alpine V3.7. In that case, start off Alpine V3.7:
$ docker run -it alpine:3.7
/ # apk add R
如果您确切需要R版本3.4.4,则可能必须从源代码进行构建.幸运的是,Artem Klevtsov提供了一个出色的现成的Dockerfile,它可以做到:
https://github.com/artemklevtsov/r-alpine/blob/master/release/Dockerfile
If you need R version 3.4.4 exactly, you may have to build it from source. Fortunately, there is an excellent ready made Dockerfile by Artem Klevtsov which does just that:
https://github.com/artemklevtsov/r-alpine/blob/master/release/Dockerfile
只需将R版本字符串替换为3.4.4并构建映像-效果很好.
Simply replace the R version string to 3.4.4 and build the image - works great.
使用特定R版本(该版本不适用于本机Alpine)的另一个选项是启用 glibc对Alpine容器的支持.
Another option for using a specific R version, which build is not available for native Alpine, is enabling glibc support on the Alpine container.
通常,Alpine建立在 musl libc 上,后者是专门的
Normally, Alpine builds on musl libc, which is a specialized libc implementation that is generally not compatible to glibc, which is the de-facto standard libc used by most other Linux distributions. With glibc installed, you should be able to run any general-purpose R Linux build on the Alpine container.
以下Dockerfile部分将启用glibc支持,从而为Alpine容器大小增加大约10MB:
The following Dockerfile portion would enable glibc support, adding some 10MB to the Alpine container size:
# Based on: https://github.com/anapsix/docker-alpine-java
FROM alpine:3.7
ENV GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc
ENV GLIBC_VERSION=2.28-r0
RUN set -ex && \
apk --update add libstdc++ curl ca-certificates && \
for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION}; \
do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
apk add --allow-untrusted /tmp/*.apk && \
rm -v /tmp/*.apk && \
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib
这篇关于如何在Alpine中安装R 3.4.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!