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?
web:
build: .
command: run
ports:
- "9000:9000"
volumes:
- .:/code
- .docker_home:/root
stdin_open: true
tty: true
FROM aknudsen/play-with-node
MAINTAINER Arve Knudsen <[email protected]>
COPY ./ /code
WORKDIR /code
EXPOSE 9000
ENTRYPOINT ["sbt"]
CMD ["run"]
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>
> 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...)
There's a GitHub issue that seems to be describing this very problem.
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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With