Reputation: 3
I have a NodeJS application that communicates with mongodb. Both services should run on Elastic Beanstalk in a "multicontainer" Docker container. It seams that the mongodb service runs through and works but my NodeJS service doesn't start. It produces empty log files and the server is not available.
I am deploying the container via EB CLI. Starting everything locally via eb local run
works fine but at the live environment the nodeJS part just doesn't start.
This is my Dockerrun.aws.json:
{
"AWSEBDockerrunVersion": 2,
"volumes": [
{
"name": "node",
"host": {
"sourcePath": "/var/app/current/node"
}
}
],
"containerDefinitions": [
{
"environment": [
{
"name": "MONGODB_DATABASE",
"value": "chat_service"
}
],
"image": "mongo",
"memory": 128,
"name": "mongo"
},
{
"essential": true,
"image": "node",
"memory": 250,
"name": "node",
"mountPoints": [
{
"sourceVolume": "node",
"containerPath": "/usr/src/app",
"sourcePath": "",
"readOnly": true
}
],
"portMappings": [
{
"hostPort": 80,
"containerPort": 3000
}
]
}
]
}
And my Dockerfile:
FROM node:carbon
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "node", "index.js" ]
I'm very new to Docker, so maybe I forgot something. Neither the CLI nor in the AWS EB Console any errors are visible and the deployment is processed without an error.
Upvotes: 0
Views: 1153
Reputation: 14903
I guess you are missing to tag
and push
& deploy
your image.
Tag your local image w.r.t your registry -
$ docker tag node-app:latest a.dkr.ecr.us-east-1.amazonaws.com/node-app:latest
Push your image -
$ docker push a.dkr.ecr.us-east-1.amazonaws.com/node-app:latest
Update JSON to use tagged image -
"essential": true,
"image": "a.dkr.ecr.us-east-1.amazonaws.com/node-app:latest",
"memory": 250,
Deploy to Elasticbeanstalk -
$ eb deploy $APP_ENV -l ${BUILD_TAG} --timeout 30
You can find ref. JSON file -
https://github.com/vivekyad4v/aws-elasticbeanstalk-multi-container
Upvotes: 1