Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 858
aknuds1 Avatar asked Apr 15 '15 19:04

aknuds1


People also ask

Does Docker compose need to be installed?

If you are on a Linux machine, you will need to install Docker Compose. After installation, you should be able to run the following and see version information.

How to install Docker Compose on Linux?

Step one: Install Docker. For Docker Compose to work on Linux, you need to have Docker installed. You can check if Docker is installed by running the following command in your terminal. In case you have Docker installed, you should see a Hello from Docker message on the terminal. If you see an error message, it means that Docker is not installed.

What is @Docker-Compose and how to use it on Mac?

docker-compose is a utility that is now a parameter in mac docker so instead of docker-compose up, its now docker compose up Show activity on this post. if you install docker from official website then docker-compose will come along with that for mac so need to either upgrade and documentation is present there.

What advantages does docker compose add to Docker?

See what advantages Docker Compose adds to Docker to make your life easier Are able to use Compose to spin up and manage multiple containers Are able to brag about automating a lot of your infrastructure In this article we’ve explored the very basics of Docker; it’s recommended to read it first if you are unfamiliar with Docker.

How to install Docker on Windows 10?

Step one: Download the Docker Desktop installer. The Docker Desktop installer can be downloaded from the official Docker website. When you navigate to the website, you will see the following page: Click on the blue button to download the Docker Desktop installer.


1 Answers

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
like image 198
Clayton SIlva Avatar answered Oct 10 '22 09:10

Clayton SIlva