Hi, I’m having difficulty with creating replicas of a docker image containing Shiny server in Docker swarm mode.
I create a docker service but no replicas are created:
$ docker stack deploy -c docker-compose_v3.yml docker-compose_v3
$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
dn2umli2xce8 docker-compose_v3_dataservice replicated 0/5
sustainableos/shiny:proj_r362_ub1804_shiny_v3 *:80->80/tcp, *:8017->3838/tcp
I can however run a single container of the docker image: When I run the docker image (as follows) a single docker container is created and I can see the Shiny app at the specified port in the browser:
docker run --name shiny_proj_v3 -dit -v '/home/shiny/webapps:/home/shiny/webapps' -v '/gis:/gis' -p 8021:3838 sustainableos/shiny:proj_r362_ub1804_shiny_v3
I’m unclear if the issue with Docker Swarm appears to be related to how I specify commands in the dockerfile. Note that I include /bin/bash in the dockerfile so that the docker container remains open. If I don’t include /bin/bash the container immediately closes.
Key elements of Dockerfile:
…
#Install Shiny server
RUN wget -c https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.14.948-amd64.deb && \
gdebi -n shiny-server-1.5.14.948-amd64.deb
# Config Shiny server
RUN sed -i -e 's+srv/shiny-server+home/shiny/webapps/proj+g' /etc/shiny-server/shiny-server.conf
# Permissions to allow shiny server to be run by shiny user (or otherwise run by root)
RUN cd /opt/shiny-server && \
chown -R shiny:shiny-app . && \
cd /opt/shiny-server/ext/node/bin && \
chown shiny:shiny-app shiny-server && \
cd /var/lib/shiny-server && \
chown -R shiny:shiny-app .
WORKDIR /home/shiny
#USER shiny
EXPOSE 3838
#CMD ["R", "-e", "shiny::runApp('/home/shiny/webapps/proj')"]
COPY start_script.sh start_script.sh
RUN chmod +x start_script.sh
CMD ./start_script.sh
The start_script.sh script:
#!/bin/bash
exec shiny-server &
/bin/bash
The docker-compose_v3.yml file:
version: "3.8"
services:
dataservice:
image: sustainableos/shiny:proj_r362_ub1804_shiny_v3
deploy:
replicas: 5
restart_policy:
condition: on-failure
ports:
- "8017:3838"
- "80:80"
volumes:
- /home/shiny/webapps/proj:/home/shiny/webapps/proj
Thanks for any suggestions.
$ docker --version
Docker version 19.03.11, build 42e35e61f3
Linux Mint 19.3 (Ubuntu 18.04)