【发布时间】:2018-06-09 13:49:00
【问题描述】:
我有一个带有 mysql (chatbot) 的 django 应用程序和带有 mongodb 的 rails 应用程序,每个都在 docker-compose 上运行 他们都单独运行 我想把它们连接在一起,我该怎么做???
我的带有 rails 的 docker-compose 文件
#with rails on the dockerfile
version: '3.6'
services:
db:
image: mongo:latest
volumes:
- ./tmp/db:/var/lib/mongo/data
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/IMS
ports:
- "3000:3000"
depends_on:
- db
bundle:
image: ims_web
volumes:
- /bundle
django 项目:
#with django on the dockerfile
version: '3.6'
services:
db:
image: mysql:latest
volumes:
- ./tmp/db:/var/lib/mysql/data
web:
build: .
command: bundle exec rails s -p 4000 -b '0.0.0.0'
volumes:
- .:/SDV
ports:
- "4000:4000"
depends_on:
- db
bundle:
image: sdv_web
volumes:
- /bundle
【问题讨论】:
-
你能提供你的 docker-compose 文件吗?您可以通过主机名在两者之间进行引用,主机名由您的服务名称定义(例如,mongodb:\\mongo-service)
-
我编辑了帖子并添加了它们
标签: ruby-on-rails python-3.x docker docker-compose