我有一个自动化测试,它启动了一个 RabbitMQ 容器,但偶尔会失败,因为容器卡在“已创建”状态,没有暴露任何端口。这种情况可以重现,但不是每次都重现。重现失败依赖于在同一节点上同时运行一组其他测试。但是,我看不出这些测试有任何明显的交互方式,特别是其他测试都没有绑定任何端口或自己运行 docker/docker-compose。
启动失败的容器示例:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f02d11bfafa4 rabbitmq:3.6.12-management "docker-entrypoint.s…" 5 minutes ago Created e26c14fe39b511e9b9eb42010a030075_rabbitmq_1
设置了详细标志的 docker-compose 摘录:
compose.cli.verbose_proxy.proxy_callable: docker create_container <- (name=u'49593b76306d11e9aedb42010a0300a2_rabbitmq_1', image='rabbitmq:3.6.12-management', labels={u'com.docker.compose.service': u'rabbitmq', u'com.docker.compose.config-hash': 'cd47649f3731353f99dc94303d03b7eff43fb767efc18dfd98918435cdfb99c6', u'com.docker.compose.project': u'49593b76306d11e9aedb42010a0300a2', u'com.docker.compose.version': u'1.23.2', u'com.docker.compose.oneoff': u'False', u'com.docker.compose.container-number': '1', 'www.example.com-rabbitmq_job_queue': 'port'}, host_config={'NetworkMode': u'49593b76306d11e9aedb42010a0300a2_default', 'Links': [], 'PortBindings': {'5672/tcp': [{'HostPort': '', 'HostIp': ''}]}, 'Binds': [], 'LogConfig': {'Type': u'', 'Config': {}}, 'VolumesFrom': []}, environment=[], volumes={}, detach=True, ports=[(u'5672', u'tcp')], networking_config={u'EndpointsConfig': {u'49593b76306d11e9aedb42010a0300a2_default': {u'IPAMConfig': {}, u'Aliases': ['rabbitmq']}}})
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
<snip>
compose.parallel.parallel_execute_iter: Failed: ServiceName(project='49593b76306d11e9aedb42010a0300a2', service='rabbitmq', number=1)
compose.parallel.feed_queue: Pending: set([])
ERROR: for 49593b76306d11e9aedb42010a0300a2_rabbitmq_1 UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=120)
compose.parallel.parallel_execute_iter: Failed: <Service: rabbitmq>
有什么办法可以解决这个问题或者进一步调查吗?