我试图通过docker-compose 1.1.0 / boot2docker 1.5.0在OS X上运行Dockerized Play app.然而,它并没有真正地发挥(原谅双关语)……
问题是应用程序必须使用伪TTY(由Docker提供)运行,这使得boot2docker在尝试连接时挂起.
我运行应用程序,通过docker-compose up,它挂起如下所示:
> docker-compose up
Recreating exampleapp_web_1...
Attaching to exampleapp_web_1
但是,如果我直接运行应用程序,没有docker-compose,它可以工作:
> 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...)
如何在我的场景中进行docker-compose工作?
泊坞窗,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
来自docker的详细输出组成
> 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 ->
Docker容器的日志
> 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,use Ctrl+D to stop and go back to the console...)
GitHub问题
有一个GitHub issue似乎在描述这个问题.
最佳答案
看到这个网址https://www.playframework.com/documentation/2.4.x/ProductionConfiguration
原文链接:https://www.f2er.com/docker/436630.html在生产中运行应用程序的步骤
1)在项目文件夹中,运行$sbt dist
2)从项目根目录执行此命令./target/universal/your-app-name -javaArguments …
在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