错误我说,我正在尝试使用docker构建容器,但无法连接sidekiq + redis,sidekiq_1 | Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)似乎sidekiq正在尝试连接至本地主机,但是由于我正在构建“理论上” redis + sidekiq + rails + postgres容器,因此无法使用本地主机,它应该在redis映像中。
我的docker-compose.yml文件是这样的:
version: '3'
services:
postgres:
image: postgres:10.5
volumes:
- my_app-postgres:/var/lib/postgresql/data
redis:
image: redis:4.0.11
volumes:
- my_app-redis:/var/lib/redis/data
web:
build: .
command: bundle exec rails server -p 3000 -b '0.0.0.0'
ports:
- '3000:3000'
depends_on:
- postgres
- redis
volumes:
- .:/my_app
env_file:
- .env
sidekiq:
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- .:/my_app
depends_on:
- postgres
- redis
env_file: …Run Code Online (Sandbox Code Playgroud)