I have a node app that uses postgres and sequelize. I have a docker file that will run my server. I also have a docker compose file that will run a web image and db image that link my docker images and connect them together.
I am able to get my server running thorugh the docker file. I am trying to use the docker-compose file to run the database with it and and get them to work. I am getting a connection error with the database that is trying to connect and I am not sure where this error is coming from...
Dockerfile
FROM node:10
WORKDIR /app
COPY package.json ./app
RUN npm install
COPY . /app
CMD npm start
EXPOSE 5585
dock compose file:
version: "2"
services:
web:
build: .
ports:
- 80:5585
command: npm start
depends_on:
- db
environment:
- DATABASE_URL=postgres://username:password@db:5432/addidas
db:
image: postgres
restart: always
ports:
- "5432:5432"
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=addidas
I am also using sequelize to connect my database with express. Do i need to change anythign to do that.
ERROR:
web_1 | Fri, 09 Nov 2018 18:26:47 GMT sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators at node_modules/sequelize/lib/sequelize.js:242:13
web_1 | server is running at http://localhost:3001
web_1 | { SequelizeConnectionRefusedError: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at connection.connect.err (/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:116:24)
web_1 | at Connection.connectingErrorHandler (/app/node_modules/pg/lib/client.js:140:14)
web_1 | at Connection.emit (events.js:182:13)
web_1 | at Socket.reportStreamError (/app/node_modules/pg/lib/connection.js:71:10)
web_1 | at Socket.emit (events.js:182:13)
web_1 | at emitErrorNT (internal/streams/destroy.js:82:8)
web_1 | at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
web_1 | at process._tickCallback (internal/process/next_tick.js:63:19)
web_1 | name: 'SequelizeConnectionRefusedError',
web_1 | parent:
web_1 | { Error: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
web_1 | errno: 'ECONNREFUSED',
web_1 | code: 'ECONNREFUSED',
web_1 | syscall: 'connect',
web_1 | address: '172.19.0.3',
web_1 | port: 5432 },
web_1 | original:
web_1 | { Error: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
web_1 | errno: 'ECONNREFUSED',
web_1 | code: 'ECONNREFUSED',
web_1 | syscall: 'connect',
web_1 | address: '172.19.0.3',
web_1 | port: 5432 } }
web_1 | { SequelizeConnectionRefusedError: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at connection.connect.err (/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:116:24)
web_1 | at Connection.connectingErrorHandler (/app/node_modules/pg/lib/client.js:140:14)
web_1 | at Connection.emit (events.js:182:13)
web_1 | at Socket.reportStreamError (/app/node_modules/pg/lib/connection.js:71:10)
web_1 | at Socket.emit (events.js:182:13)
web_1 | at emitErrorNT (internal/streams/destroy.js:82:8)
web_1 | at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
web_1 | at process._tickCallback (internal/process/next_tick.js:63:19)
web_1 | name: 'SequelizeConnectionRefusedError',
web_1 | parent:
web_1 | { Error: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
web_1 | errno: 'ECONNREFUSED',
web_1 | code: 'ECONNREFUSED',
web_1 | syscall: 'connect',
web_1 | address: '172.19.0.3',
web_1 | port: 5432 },
web_1 | original:
web_1 | { Error: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
web_1 | errno: 'ECONNREFUSED',
web_1 | code: 'ECONNREFUSED',
web_1 | syscall: 'connect',
web_1 | address: '172.19.0.3',
web_1 | port: 5432 } }