This readme allows you to install a docker image of openCPU which contains a demonstration R web application, the latest stable version of phisWSClientR package and a server version of rstudio server.
Prerequisites
:
- Access to root account
- Able to use the 8004
- 1. Install automatically docker and opencpu docker container with
install-docker-ocpu.sh
script - 2. Install manually docker and opencpu container (If docker is already installed go to step 2.4)
- 3. Run docker container
- 4. How to install a custom openCPU application
- 5. How to move an R package from host to container {host_scripts_path} and install it
- 6. To uninstall docker :
Click here to see the steps to install/configure docker and install opensilex opencpu container with install-docker-ocpu.sh
.
This script allow you to install easily docker, configure it for your purpose and install opensilex opencpu docker.
Usage: install-docker-ocpu.sh [
Usage: install-docker-ocpu.sh [
[-i --install-all docker-rstudio-password] regroup all other functions
[-d --install-docker ] For Ubuntu and Debian - installation documentation date : 2019-06-14
[-c --configure-docker] For Ubuntu and Debian
[-u --docker-dns-reconfigure] For Ubuntu and Debian
[-n --configure-network] # add 172.17.0.1 to dnsmasq for Ubuntu only
[-o --install-ocpu-docker-with-password docker-rstudio-password] For Ubuntu and Debian
[-h --help]
]
Three steps are needed to install and run this docker container :
It is better to install docker from the
official documentation
. install-docker-ocpu.sh -d
. install-docker-ocpu.sh -c
. install-docker-ocpu.sh -o {password for rstudio server}
Example : . install-docker-ocpu.sh -o secret
If you have some issues with internet connection configuration (DNS server). You can use these following commands.
. install-docker-ocpu.sh -u
If the container is successfully installed, go to the step 3.3 .
Click here to see steps to install manually docker opencpu
- Follow the Installation guide. (recommended)
# create docker group if it doesn't exist
sudo groupadd docker
# put your user in docker group
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated. or use :
su - ${USER}
For more information go to https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user
sudo systemctl enable docker
2.7. (Optional) Configure Docker DNS which allows docker containers it to connect to internet (Only if you have issue with DNS)
Run the following command :
nmcli dev show | grep 'IP4.DNS'
The excepted result is above :
IP4.DNS[1]: 147.100.116.5
IP4.DNS[2]: 147.100.126.4
more /etc/resolv.conf
# Generated by NetworkManager
nameserver 147.100.116.5
nameserver 147.100.126.4
#A clean solution is to configure docker+dnsmasq so than DNS #requests from the docker container are forwarded to the dnsmasq #daemon running on the host.
#For that, you need to configure dnsmasq to listen to the network #interface used by docker, by adding a file /etc/NetworkManager/#dnsmasq.d/docker-bridge.conf:
sudo touch /etc/NetworkManager/dnsmasq.d/docker-bridge.conf
echo "listen-address=172.17.0.1" > /etc/NetworkManager/dnsmasq.d/docker-bridge.conf
sudo service network-manager restart
#You can add 172.17.0.1, i.e. the host's IP #address from within docker, to the list of DNS servers in docker's configuration file.
echo "{\"dns\": [\"172.17.0.1\",\"YOUR_DNS_1_IP_HERE\", \"YOUR_DNS_2_IP_HERE\", \"OTHER_DNS_IP_HERE\",....]}" > /etc/docker/daemon.json
- daemon.json file content example :
{
"dns": ["172.17.0.1","147.100.116.5", "147.100.126.4"]
}
service docker restart
docker build --no-cache {repository or local directory} -t opensilex/opencpu
docker build --no-cache https://github.com/OpenSILEX/opensilex-opencpu-docker.git -t opensilex/opencpu
- example :
docker run -d -t -p 8004:8004 -e USER_PASSWORD=secret --name=opensilex-ocpu opensilex/opencpu:latest
# or
# if you want to link a host folder and container folder
# docker run -v {host_scripts_path}:/home/opencpu/scripts --name opencpu-server -t -p 8004:8004 opencpu/rstudio
By default, the docker file already contains "opensilex/opensilex-datavis-rapp-demo" application and "phisWSClientR" package.
You can now go to : http://localhost:8004/ocpu/apps/opensilex/opensilex-datavis-rapp-demo/www/ .
You will able to try the demo R application.
Run in terminal :
docker stop opensilex-ocpu
Run in terminal :
docker start opensilex-ocpu
Run in terminal :
docker stop opensilex-ocpu
docker rm opensilex-ocpu
You can connect to the http://{serverIp}:8004/rstudio
your favorite R IDE
The default password is opencpu but it can be modified. (coming soon ...)
And run this command
opencpu::install_apps("opensilex/opensilex-datavis-rapp-demo")
or you can connect to the docker container :
docker exec -i -t container_name /bin/bash
# switch to non root user
su opencpu
# install package
R -e 'opencpu::install_apps("opensilex/opensilex-datavis-rapp-demo")'
Click here to see steps to move an R package from host to container
You can connect to the http://{serverIp}:8005/rstudio
your favorite R IDE
The default password is opencpu but it can be modified. (coming soon ...)
And run this command
remotes::install_github("openSILEX/phisWSClientR", build_vignettes=TRUE, ref="v1.3.0", upgrade ="always")
or you can connect to the docker container :
docker exec -i -t container_name /bin/bash
# switch to non root user
su opencpu
# install package
R -e 'remotes::install_github("openSILEX/phisWSClientR", build_vignettes=TRUE,ref="v1.3.0",upgrade ="always")'
If you have set a link between {host_scripts_path}
and /home/opencpu/scripts
.
You can move your R package archive (tar.gz) in {host_scripts_path}
in order to be able to access
it in the container.
Now can connect to the docker container and install your package from the source :
docker exec -i -t container_name /bin/bash
# switch to non root user
su opencpu
# install package
R -e 'install.packages("/home/opencpu/scripts/phisWSClientR_1.3.0.tar.gz",repos=NULL,type ="source")'
Follow instructions at :
https://docs.docker.com/install/linux/docker-ce/debian/#uninstall-docker-ce