So I'm writing a node application, and my docker-compose.yml looks like:
version: '2'
services:
redis:
image: "redis:latest"
web:
build: .
ports:
- "3000:3000"
volumes:
- .:/app
links:
- redis
emailworker:
build: .
env_file:
- ./.env
command: node ./lib/workers/email.js
volumes:
- .:/app
links:
- redis
smsworker:
build: .
env_file:
- ./.env
command: node ./lib/workers/sms.js
volumes:
- .:/app
links:
- redis
Pretty straight forward, a webserver, and two workers to process email and sms jobs. All has been great, until this afternoon, where nothing seemed to change, but I can not longer connect to the redis container when my app boots up. I run docker-compose up
and I get the following error when trying to connect to redis using the kue
node module:
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
My kue
connection to redis looks like:
const kue = require('kue'),
queue = kue.createQueue({
root: __dirname,
redis: {
host: 'redis',
port: 6379
}
});
queue.on('error', err => {
console.log('QUEUE ERROR: ', err);
});
Any ideas where I'm going wrong here? I just set this up last night and emails were happily being sent, and like I mentioned, the only thing that would have changed is app code in the web service. I'm developing on a Mac if that makes a difference and have the latest version of docker and docker-compose. A docker ps
after doing a docker-compose up
shows:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3af92333ad53 expapi_web "yarn docker" About a minute ago Up About a minute 0.0.0.0:3000->3000/tcp expapi_web_1
d26f1d81ad22 expapi_emailworker "node ./lib/workers/e" About a minute ago Up About a minute 3000/tcp expapi_emailworker_1
1695ec819777 expapi_smsworker "node ./lib/workers/s" About a minute ago Up About a minute 3000/tcp expapi_smsworker_1
5cb6701f3586 redis:latest "docker-entrypoint.sh" About a minute ago Up About a minute 6379/tcp expapi_redis_1