Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use R language in Docker

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use R language in Docker related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this article on how to use R language in Docker, let's take a look.

1: easy development

The flagship of the OpenCPU system is the OpenCPU server: it is a mature and powerful Linux stack for embedding R in systems and applications. Because OpenCPU is completely open source, we can build and distribute it on DockerHub. You can start a ready-to-use Linux server for OpenCPU and RStudio (using port 8004 or 80) using the following command:

Docker run-t-p 8004 8004 opencpu/rstudio

Now all you have to do is open http://localhost:8004/ocpu/ and http://localhost:8004/rstudio/ in your browser! Use the user opencpu (password: opencpu) login in rstudio to build or install the application. For more information, see the README file.

Docker makes it easy to get started with OpenCPU. The container gives you a fully flexible Linux machine without having to install anything on the system. You can install software packages or applications through the rstudio server, or you can use docker exec to enter the root shell of the running server:

# Lookup the container IDdocker ps# Drop a shelldocker exec-I-t eec1cdae3228 / bin/bash

You can install other software in the server's shell, customize apache2's httpd configuration (auth, proxy, etc.), adjust the R option, and optimize performance by preloading data or packages, etc.

2: publish and deploy through DockerHub

Most powerful of all, Docker can be released and deployed through DockerHub. To create a completely independent application container, simply use the standard opencpu image and add your program.

For the purposes of this article, I packaged some sample programs as docker containers by adding a very simple "Dockerfile" to each repository. For example, the Dockerfile of nabel contains the following:

FROM opencpu/baseRUN R-e 'devtools::install_github ("rwebapps/nabel")'

It uses a standard opencpu/base image and installs nabel from the Github repository. Finally, a completely isolated and independent program is obtained. Anyone can start the program using the following command:

Docker run-d 8004 8004 rwebapps/nabel

-d listens on port 8004 on behalf of the daemon. Obviously, you can adjust Dockerfile to install any other software or set up the programs you need.

Containerized deployment demonstrates the true power of Docker: it can release stand-alone software that can be used out of the box without installing any software or relying on paid hosted services. If you prefer professional hosting, there will be many companies that will be happy to host docker programs for you on scalable infrastructure.

3: cross-platform construction

There is also a third way Docker is used for OpenCPU. Every time we release, we build 6 operating system opencpu-server installs, which are published on https://archive.opencpu.org. This process has been fully automated using DockerHub. The following image automatically builds all stacks from the source code:

Opencpu/ubuntu-16.04opencpu/debian-9opencpu/fedora-25opencpu/fedora-26opencpu/centos-6opencpu/centos-7

When a new version is released on GitHub, DockerHub automatically rebuilds this image. All you have to do is run a script that retrieves the image and copies the opencpu-server binaries to the archive server.

This is the end of the article on "how to use R language in Docker". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to use R language in Docker". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report