9

I have a development setup where I need multiple containers running different services, and I'm trying to use Fig to achieve this. Everything else works fine, but one of these services is a Play Framework app, and it does not want to stay running unless it gets a pseudo-TTY. This would be fine and good, but since I want to coordinate these multiple containers, I want to fig up, and that command does not seem to allocate pseudo-TTY's, so the process dies immediately after startup, and all the containers along with it.

I've created a repository with a showcase of this problem that anybody can just clone and run, the instructions are in the README. If anybody can shed any light on how to create e.g. a middleman script that would keep the app running, or really any other solution where I could fig up my linked container setup, that'd be brilliant.

Alternatively, if anybody is using any other methods of coordinating multiple containers like this, like maybe a nice shell script runner that manages things, I welcome your insight.

edit: I changed the accepted answer because the new one actually solves the problem. The workaround answer still has valuable info, though.

Ilkka
  • 2,644
  • 1
  • 23
  • 27
  • Walp, I've given up. Since Play Framework contains the sbt native packager, one can `./activator docker:stage` and then run and build that. See http://www.scala-sbt.org/sbt-native-packager/DetailedTopics/docker.html. – Ilkka Nov 14 '14 at 20:33

3 Answers3

11

Fig has been replaced by Docker Compose, and in your docker-compose.yml file you can now add the stdin_open: true setting, which should fix this issue:

web:  
  image: brikis98/ping-play
  ports:
    - "9000:9000"
  stdin_open: true

In the example above, the brikis98/ping-play image is a Play app that executes activator run by default. If I run docker-compose up on the YAML file above, the Play app boots up and keeps running instead of exiting immediately.

Yevgeniy Brikman
  • 8,711
  • 6
  • 46
  • 60
6

A Play! run command orchestrated via Fig currently will always exit once launched. It is the same behaviour if you resumed the Fig created container (docker start -i). Basically this mirrors what happens when you launch the Play/SBT/Activator REPL via a run command as a Docker background daemon it will also exit (docker run -d).

The workaround as Ilkka already commented is to package the Play application to able to run on its own. Either via the stage and/or start commands https://playframework.com/documentation/2.3.x/Production or as distribution via https://playframework.com/documentation/2.3.x/ProductionDist.

For example if Docker image includes application source then you can add the stage command to it

ADD myapplication /var/local/application

WORKDIR /var/local/application 

RUN /usr/local/bin/activator stage

And in the fig.yml your command can be

command: target/universal/stage/bin/myapplication

You can see an example Dockerfile and yml file with this Docker Compose (Fig's successor) project

flurdy
  • 3,782
  • 29
  • 31
0

fig run is supposed to use the TTY terminal. so you could try

fig run test ./activator start
Usman Ismail
  • 17,999
  • 14
  • 83
  • 165