aknuds1
aknuds1

Reputation: 68067

How do I make docker-compose on OS X work with a Play app?

I am trying to run a Dockerized Play app on OS X via docker-compose 1.1.0/boot2docker 1.5.0. However, it doesn't really, well, play (pardon the pun)...

The problem is that the app must run with a pseudo TTY (provided by Docker), and this makes boot2docker hang while trying to attach.

I run the app, through docker-compose up, and it hangs as shown below:

> docker-compose up
Recreating exampleapp_web_1...
Attaching to exampleapp_web_1

However, if I run the app directly, without docker-compose, it works:

> docker rm exampleapp_web_1 ; docker run -p 9000:9000 -ti --name exampleapp_web_1 -v `pwd`:/code -v `pwd`/.docker_home:/root exampleapp_web
[info] Loading project definition from /code/project
[info] Set current project to example-app (in build file:/code/)

--- (Running the application, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

How do I make docker-compose work in my scenario?

docker-compose.yml

web:
  build: .
  command: run
  ports:
    - "9000:9000"
  volumes:
    - .:/code
    - .docker_home:/root
  stdin_open: true
  tty: true

Dockerfile

FROM aknudsen/play-with-node
MAINTAINER Arve Knudsen <[email protected]>

COPY ./ /code
WORKDIR /code

EXPOSE 9000

ENTRYPOINT ["sbt"]
CMD ["run"]

Verbose output from docker-compose up

> docker-compose --verbose up
Compose version 1.1.0
Docker base_url: https://192.168.59.103:2376
Docker version: KernelVersion=3.18.5-tinycore64, Arch=amd64, ApiVersion=1.17, Version=1.5.0, GitCommit=a8a31ef, Os=linux, GoVersion=go1.4.1
docker containers <- (all=True)
docker containers -> (list with 3 items)
Creating exampleapp_web_1...
docker containers <- (all=True)
docker containers -> (list with 3 items)
docker images <- (name=u'exampleapp_web')
docker images -> (list with 1 items)
docker create_container <- (tty=True, name=u'exampleapp_web_1', image=u'exampleapp_web', stdin_open=True, environment={}, command='run', volumes={u'/code': {}, u'/root': {}}, detach=False, ports=[u'9000'])
docker create_container -> {u'Id': u'dc0ebc7e34ea8793023a968725ab696e1a3d60341105e84e81ace776952f55d8',
 u'Warnings': None}
docker inspect_container <- (u'dc0ebc7e34ea8793023a968725ab696e1a3d60341105e84e81ace776952f55d8')
docker inspect_container -> {u'AppArmorProfile': u'',
 u'Args': [u'run'],
 u'Config': {u'AttachStderr': True,
             u'AttachStdin': True,
             u'AttachStdout': True,
             u'Cmd': [u'run'],
             u'CpuShares': 0,
             u'Cpuset': u'',
             u'Domainname': u'',
             u'Entrypoint': [u'sbt'],
...
docker start <- (u'dc0ebc7e34ea8793023a968725ab696e1a3d60341105e84e81ace776952f55d8', links=[], cap_add=None, restart_policy=None, dns_search=None, network_mode=u'bridge', binds={u'/Users/arve/Projects/example-app/.docker_home': {u'bind': u'/root', u'ro': False}, u'/Users/arve/Projects/example-app': {u'bind': u'/code', u'ro': False}}, dns=None, volumes_from=[], port_bindings={u'9000': [u'9000']}, cap_drop=None, privileged=False)
docker start -> None
docker containers <- (all=False)
docker containers -> (list with 2 items)
Attaching to exampleapp_web_1
docker attach <- (u'dc0ebc7e34ea8793023a968725ab696e1a3d60341105e84e81ace776952f55d8', stderr=1, logs=1, stream=1, stdout=1)
docker attach -> <generator object _multiplexed_response_stream_helper at 0x1062db2d0>

Log of Docker container

> docker logs exampleapp_web_1
[info] Loading project definition from /code/project
[info] Set current project to example-app (in build file:/code/)

--- (Running the application, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

GitHub Issue

There's a GitHub issue that seems to be describing this very problem.

Upvotes: 7

Views: 2986

Answers (1)

Clayton SIlva
Clayton SIlva

Reputation: 45

see this url https://www.playframework.com/documentation/2.4.x/ProductionConfiguration

steps to run application in production

1) in project folder, run $sbt dist 2) execute this command from project root ./target/universal/your-app-name -javaArguments ...

in docker-compose

web:
build: .
command: sbt dist && ./target/universal/app-name -JavaArguments
ports:
  - "9000:9000"
volumes:
  - .:/code
  - .docker_home:/root
stdin_open: true
tty: true

Upvotes: 1

Related Questions