Docker“正常停止”本身在'docker-compose up`而不是'docker-compose run --entrypoint` [英] Docker "Gracefully stopping" itself during `docker-compose up` but not `docker-compose run --entrypoint`

查看:309
本文介绍了Docker“正常停止”本身在'docker-compose up`而不是'docker-compose run --entrypoint`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动一个具有 docker-compose up 的Docker容器时,它像往常一样启动,但是最终容器自动退出,没有任何可以告诉的容器在详细日志

When I start a Docker container with docker-compose up, it starts up as usual, but eventually the container automatically exits without anything that I can tell is useful in the verbose log.

当我代替运行 docker-compose up --entrypoint run-tests.sh Docker容器表示自然停止,并停止所有容器。

When I instead run docker-compose up --entrypoint run-tests.sh with the same docker-compose.yml configuration (with the same entrypoint set) and the same Dockerfile, the Docker container says "Gracefully stopping" on its own and stops all containers.

不好的行为似乎来自于运行 docker-compise up 而不是等效的 docker-compose运行

The bad behaviour seems to come from running docker-compose up instead of the equivalent docker-compose run.

容器似乎在关闭之前保持不变的时间。

The container seems to stay up for varying times before it shuts down. In one instance it stayed up for 7 minutes, different times in others.

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

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', u'build.sh && play auto-test'],
...
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'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'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`.

docker-compose.yml p>

docker-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的存储库中有一个公开问题

I was having the same problem. There's an open issue for that at Compose's repository.

在有人提出的解决方案的问题中,运行 docker-compose up -d 。这样容器即使连接失败也会继续运行。
要查看容器日志,只需运行 docker-compose logs

In the issue someone suggested, as a workaround, to run docker-compose up -d. That way containers will keep running even if there's a connection failure. To see the container logs just run docker-compose logs.

该建议解决了现在无需担心降级撰写。

That suggestion solved the problem for now without having to worry to downgrade Compose.

这篇关于Docker“正常停止”本身在'docker-compose up`而不是'docker-compose run --entrypoint`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆