Paul
Paul

Reputation: 2959

Docker app fails to launch with shinyproxy in docker-compose, works with run

I have a shinyproxy app that works fine with docker run ...

docker run --name=shinyproxy -d -v /var/run/docker.sock:/var/run/docker.sock --net telethonkids-net -p 80:8080 --rm telethonkids/shinyproxy

by when I try the following docker-compose shinyproxy loads on the browser, but the app times out when trying to start (Container unresponsive):

version: "3.6"
services:
    shinyproxy:
      build:
        context: ./shinyproxy
        dockerfile: Dockerfile
      networks:
        - telethonkids-net
      volumes:
        - "/var/run/docker.sock:/var/run/docker.sock"
      ports:
        - 80:8080

networks:
  telethonkids-net:

I'm running this on a Ubuntu 18.04 virtual box. There are a few other questions with similar titles, but none that I saw that matched my problem.

Here's my application.yaml

proxy:
  title: Shiny Proxy Landing Page
  hide-navbar: true
  landing-page: /
  port: 8080
  docker:
    internal-networking: true
  specs:
  - id: id1
    display-name: xxx
    description: yyy
    container-cmd: ["/usr/bin/shiny-server.sh"]
    container-image: telethonkids/zzz
    container-env:
      user: 'shiny'
      environment:
        - APPLICATION_LOGS_TO_STDOUT=false

Shinyproxy Dockerfile:

FROM openjdk:8-jre

RUN mkdir -p /opt/shinyproxy/
RUN wget https://www.shinyproxy.io/downloads/shinyproxy-2.1.0.jar -O /opt/shinyproxy/shinyproxy.jar
COPY application.yml /opt/shinyproxy/application.yml

WORKDIR /opt/shinyproxy/
CMD ["java", "-jar", "/opt/shinyproxy/shinyproxy.jar"]

Upvotes: 2

Views: 1530

Answers (2)

Geiser
Geiser

Reputation: 1079

Since docker-compose v3.5, you can just create the network from inside the docker-compose.yml instead of having to create it before running docker-compose up

As an example:

version: '3.7'

services:
  shinyproxy:
    image: myimage
    restart: unless-stopped
    container_name: "ShinyProxy"
    networks:
      shinyproxy-net:

networks:
  shinyproxy-net:
    name: shinyproxy-net

So now a simply docker-compose up creates the network

Reference: https://github.com/docker/compose/issues/3736#issuecomment-365318122

Upvotes: 1

Paul
Paul

Reputation: 2959

I think this one comes down to a rookie error. I had created a network to run my app via. docker run --net telethonkids-net. This was causing issues when trying to use the same network inside docker-compose with:

networks: telethonkids-net:

After reading the documentation a bit more closely, I could use this pre-created network with the following:

networks:
  default:
    external:
      name: telethonkids-net

and adding

  networks:
    default:

to the shinyproxy service.

And the app started. The fix was to just remove the created network in docker and create it in docker-compose. I also needed to name the network so it conformed to what I had in shinyproxy/application.yml.

networks:
  telethonkids-net:
    name: telethonkids-net

Upvotes: 3

Related Questions