Stack information :
BE : NodeJS App, MongoDB
FE : AngularJS App
Use case : I am deploying BE(NodeJS) application on AWS ECS along with MongoDB. There is a task definition (AWS) in which there should be both the containers attached so that Mongo container can be linked to the NodeJS container. Mongo container is from docker hub registry registry.hub.docker.com/library/mongo:latest
Please note I have also subscribed to the CloudWatch Logs for the containers.
I am also providing the MONGO_INITDB_ROOT_PASSWORD & MONGO_INITDB_ROOT_USERNAME as new user environment variables.
Problem : As soon as the service bootstraps NodeJS container, it gets failed with below error.
2019-05-28T14:15:23.208+0000 I CONTROL [main] ERROR: Cannot write pid file to /tmp/docker-entrypoint-temp-mongod.pid: Unknown error
Result : As a result, mongo is not able to get started and NodeJS app is unable to operate on the db. I want this db operations within container (ECS) as a solution.
Please guide what I am doing wrong here!! Kindly Help!
Why it differs from this answer/question : Because in my case the application along with MongoDB is running in container environment and container (Node container) is all responsible for bootstrapping it or restarting the mongo service. Also, the error I am facing is Unknown Error.
EDIT : Dockerfile
FROM node:8-alpine
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# RUN npm audit
# Bundle app source
#COPY . /usr/src/app
COPY . .
EXPOSE 9000
CMD [ "npm", "start" ]