Comments (5)
I ran into this issue myself a couple months ago. From what I recall, for security reasons Shiny isn't able to access environmental variables set by Docker. One workaround is to define your environmental variables in a .Renviron file and copy this file into /home/shiny/
.
For example, my .Renviron file:
DBHOST=db
DBNAME=txdb
DBUSER=postgres
DBPASS=XXXXXXXXXXX
And my Dockerfile:
FROM rocker/shiny-verse
RUN R -e "install.packages(c('data.table', 'DT', 'leaflet'), repos='https://cran.rstudio.com/')"
RUN rm -rf /srv/shiny-server
WORKDIR /srv/shiny-server
COPY --chown=shiny:shiny . ./
COPY --chown=shiny:shiny .Renviron /home/shiny/.Renviron
EXPOSE 3838
from shiny.
Thanks, I ended up doing something pretty similar to that. It's not an ideal solution for me though since some of my deployments build from github or dockerhub and I don't want my environment variables on a public repo.
Would be ideal if shiny server could access environment variables set on the container rather than wiping them as it currently does. As you say doesn't seem to be an option currently.
from shiny.
👍 Thanks all for the comments. I agree it would be nicer if rstudio-server and shiny-server read env vars from the environment instead of only though the .Renviron
files, but afaik that's the only option and is what we do in our Dockerfile recipes as well. Feel free to raise the issue with the RStudio developers, as this is ultimately their choice. They have been gracious in allowing Rocker explicit permission to package their open source products this way, and obviously they have commercial products in the same space.
We welcome other suggestions for working around these issues as well.
from shiny.
Here's my workaround: I override the CMD and simply dump all env variables into .Renviron:
CMD env > /home/shiny/.Renviron && shiny-server
This way you can still define the env variables in e.g. your docker-compose.yml or via an env file and don't have to hard-code into the Dockerfile.
I have a question about the security aspect: If shiny shouldn't access env variables for security reasons (why?) then 'read-only' access would be fine? I could only imagine, if shiny writes some env variables, that would pose a risk?
from shiny.
For Images with tags >= 4.0.0, which are currently maintained, this issue was resolved by rocker-org/rocker-versioned2#320.
So I close this issue.
from shiny.
Related Issues (20)
- /usr/bin/shiny-server.sh: no such file or directory error HOT 2
- Shiny version HOT 2
- Remove /tmp/downloaded_packages HOT 4
- no xtail in Shiny:Devel HOT 1
- New Version of Shiny Server HOT 5
- Update shiny-verse to later R-ver HOT 3
- nginx reverse proxy - shiny server issue HOT 1
- request for merge of shiny-verse and verse (i.e. Tidyverse, LaTeX, and Shiny all together) HOT 2
- Permission denied when running rocker/shiny-verse and rocker/shiny images HOT 4
- Regression for running as non-root user? HOT 6
- [Resolved] Where is application output? print, logging, etc. HOT 2
- Security Vulnerabilities HOT 3
- rocker/shiny-verse latest vs 3.6.3 HOT 4
- rocker/shiny-verse latest vs 3.6.3 HOT 1
- Provide a bootstrap endpoint HOT 1
- doesn't work on ARM architecture HOT 3
- Basic setup for 3.6.3 does not work for 4.0.3? HOT 1
- Missing git tags HOT 1
- Unable to save to mounted volume HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shiny.