【发布时间】:2021-10-28 05:57:57
【问题描述】:
[docker-compose 问题]
大家好!我已经被困了一段时间,所以希望我们可以一起调试。
我正在使用 docker compose 来启动三个独立的服务。 一切都建立起来很棒。应用程序的健康检查通过,服务相互联系,但我似乎无法从主机卷曲我的应用程序。
我已经为 app.ports 尝试了以下值:
“127.0.0.1:3000:3000” “3000:3000” "0.0.0.0:3000:3000"
我也尝试使用“主机”网络运行它,但这似乎也不起作用,我不喜欢它,因为显然 Mac 不支持它,而我的本地开发人员环境是 Macosx。产品服务器是 ubuntu。
我已经尝试明确定义默认的网桥网络:
networks:
default:
driver: bridge
这是我的 docker-compose.yml
version: "2.4"
services:
rabbitmq:
image: rabbitmq
volumes:
- ${ML_FILE_PATH}/taskqueue/config/:/etc/rabbitmq/
environment:
LC_ALL: "C.UTF-8"
LANG: "C.UTF-8"
celery-worker:
image: ${ML_IMAGE_NAME}
entrypoint: "celery --broker='amqp://<user>:<password>@rabbitmq:5672//' -A taskqueue.celeryapp worker --uid 1111"
runtime: ${RUNTIME} ## either "runc" if running locally on debug mode or "nvidia" on production with multi processors
volumes:
- ${ML_FILE_PATH}:/host
depends_on:
- rabbitmq
- app
environment:
LC_ALL: "C.UTF-8"
LANG: "C.UTF-8"
MPLCONFIGDIR: /host/tmp
volumes:
- ${ML_FILE_PATH}:/host
celery-beat:
image: ${ML_IMAGE_NAME}
entrypoint: "celery --broker='amqp://<user>:<password>@rabbitmq:5672//' -A taskqueue.celeryapp beat --uid 1111"
runtime: ${RUNTIME} ## either "runc" if running locally on debug mode or "nvidia" on production with multi processors
depends_on:
- rabbitmq
- app
environment:
LC_ALL: "C.UTF-8"
LANG: "C.UTF-8"
MPLCONFIGDIR: /host/tmp
volumes:
- ${ML_FILE_PATH}:/host
app:
build: .
entrypoint: ${ML_ENTRYPOINT} # just starts a flask app
image: ${ML_IMAGE_NAME}
ports:
- "3000:3000"
expose:
- "3000"
volumes:
- ${ML_FILE_PATH}:/host
restart: always
runtime: ${RUNTIME}
healthcheck:
test: ["CMD", "curl", "http:/localhost:3000/?requestType=health-check"]
start_period: 30s
interval: 30s
timeout: 5s
environment:
SCHEDULER: "off"
TZ: "UTC"
LC_ALL: "C.UTF-8"
LANG: "C.UTF-8"
我可以按预期从容器内访问服务。
我不确定我错过了什么。非常感谢您的帮助!
【问题讨论】:
标签: docker docker-compose