Docker在“docker-compose”期间“优雅地停止”自己但不是“docker-compose run –entrypoint”

前端之家收集整理的这篇文章主要介绍了Docker在“docker-compose”期间“优雅地停止”自己但不是“docker-compose run –entrypoint”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

当我使用docker-compose启动Docker容器时,它会像往常一样启动,但最终容器会自动退出而没有任何我能说明的详细日志中有用的东西.

当我改为使用相同的docker-compose.yml配置(具有相同的入口点集)和相同的Dockerfile运行docker-compose up –entrypoint run-tests.sh时,Docker容器自行说“正常停止”并停止所有容器.

坏行为似乎来自于运行docker-compose而不是等效的docker-compose运行.

容器在关闭之前似乎保持不同的时间.在一个例子中,它在其他情况下保持了7分钟,不同时间.

有谁知道如何解决这个问题?

Docker版本:

Docker version 1.9.0,build 76d6bc9
docker-compose version: 1.5.0
docker-machine version 0.5.0 (HEAD)

docker-compose –verbose up log:

docker-compose --verbose --project-name monkeycore up monkeycore-autotest
... lots of startup log (let me know if you need to see this) ...
# Scala Play1 Framework tests,not likely relevant
monkeycore-autotest_1 | ~ MonkeyTest...                   PASSED     30s
monkeycore-autotest_1 | ~ WhateverDataTest...             PASSED     33s
monkeycore-autotest_1 | ~ SauceTest...                    PASSED     1 min 44s
Gracefully stopping... (press Ctrl+C again to force)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False,filters={u'label': [u'com.docker.compose.project=monkeycore',u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 2 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'617bf28c3f7ae3779f383f7e2a96f66e552e92f755a15d07ac6b73329ba3860f')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {u'AppArmorProfile': u'',u'Args': [u'-c',u'build.sh && play auto-test'],u'Config': {u'AttachStderr': False,u'AttachStdin': False,u'AttachStdout': False,u'Cmd': None,u'cpuShares': 0,u'cpuset': u'',u'Domainname': u'',u'Entrypoint': [u'bash',u'-c',...
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'4963e9287ed10d587a79f57a52eaf86c07c6947b2119072bd5d68a3ed0eb161e')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {u'AppArmorProfile': u'',u'Args': [u'/usr/local/etc/redis/redis.conf'],u'Entrypoint': [u'redis-server',...
Stopping monkeycore_monkeycore-autotest_1 ...
compose.cli.verbose_proxy.proxy_callable: docker stop <- (u'617bf28c3f7ae3779f383f7e2a96f66e552e92f755a15d07ac6b73329ba3860f',timeout=10)
Stopping monkeycore_monkeycore-autotest_1 ... done
ERROR: compose.cli.main.main: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.

泊坞窗,compose.yml:

monkeycore-base:
    build: ../
    dockerfile: "docker/monkeycore/Dockerfile"
    ports:
      - "8000:8000"
      - "8082:8082"
      - "9000:9000"
    stdin_open: true
    tty: true
    working_dir: "/path/to/dir"
    volumes:
      - src:dest
    environment:
      LOTS_OF_ENVIRONMENT_VARIABLES: "defined"

monkeycore-autotest:
    extends:
      service: monkeycore-base
    links:
      - redis
    entrypoint: "run-tests.sh"

redis:
    build: ./redis
    ports:
      - "6379:6379"
最佳答案
我遇到了同样的问题.在Compose的存储库中有一个open issue.

在这个问题中,有人建议,作为一种解决方法,运行docker-compose up -d.这样,即使连接失败,容器也会继续运行.
要查看容器日志,只需运行docker-compose logs.

这个建议现在解决了这个问题,而不必担心降级Compose.

猜你在找的Docker相关文章