Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-compose daemon exiting

So I'm using the Play framework with Docker (specifically using this image), and trying to get a server up and running.

Doing

$ sudo docker-compose run web activator run

works just as expected: the webserver starts up and stays up to accept incoming requests.

But then I try

$ sudo docker-compose up -d

and

$ sudo docker-compose logs
...
web_1      | [info]     [SUCCESSFUL ] org.ow2.asm#asm-analysis;4.1!asm-analysis.jar (16ms)
web_1      | [info] downloading file:/activator-1.3.2/repository/org.ow2.asm/asm-util/4.1/jars/asm-util.jar ...
web_1      | [info]     [SUCCESSFUL ] org.ow2.asm#asm-util;4.1!asm-util.jar (32ms)
web_1      | [info] Done updating.
web_1      | 
web_1      | --- (Running the application from SBT, auto-reloading is enabled) ---
web_1      | 
web_1      | [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
web_1      | 
web_1      | (Server started, use Ctrl+D to stop and go back to the console...)
web_1      | 
web_1      | 
web_1      | [success] Total time: 356 s, completed May 11, 2015 6:44:20 AM
shallwedebate_web_1 exited with code 0
amos@lub:/ShallWeDebate$ sudo docker-compose ps
      Name             Command             State              Ports       
-------------------------------------------------------------------------
shallwedebate_da   /docker-           Up                 5432/tcp         
tabase_1           entrypoint.sh                                          
                   postgres                                               
shallwedebate_we   activator run      Exit 0                              
b_1  

It exits! Why is that? Why doesn't it keep running like when I do docker-compose run?

EDIT -- My docker-compose.yml file

database:
  image: postgres:9.1
  volumes:
    - /ShallWeDebate/postgres-entrypoint:/docker-entrypoint-initdb.d:ro
  env_file:
    - ./vars.env
web:
  image: ingensi/play-framework
  volumes:
    - /ShallWeDebate:/app:rw
  env_file:
    - ./vars.env
  links:
    - database
  ports:
    - "80:9000"
like image 846
wrongusername Avatar asked Dec 25 '22 19:12

wrongusername


2 Answers

If you want a solution that works with the Play app in development mode, rather than production mode, you can add the stdin_open: true setting to your docker-compose.yml file:

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.

like image 200
Yevgeniy Brikman Avatar answered Jan 12 '23 18:01

Yevgeniy Brikman


The problem is related to Play Framework. When running your app with activator, it tries to attach to stdin waiting Ctrl+D to finish the app. Running the app with activator command and without stdin is not supported right now by Play Framework. You found a workaround to get this working (running your app from an interactive docker container). Probably you could get it working with fig hacking a little bit, allocating some way a pseudo-tty, but the best solution would be Play Framework supports this feature. There are some issues related with this particular problem: typesafehub/activator #939, playframework/playframework #4001

like image 20
Javier Cortejoso Avatar answered Jan 12 '23 20:01

Javier Cortejoso