# How To Build Docker Image With NodeJS App

**URL:** <https://forums.docker.com/t/how-to-build-docker-image-with-nodejs-app/319>\
**Category:** General\
**Created:** [October 29, 2014, 8:45pm UTC](https://forums.docker.com/t/how-to-build-docker-image-with-nodejs-app/319 "2014-10-29T20:45:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![billpaxton](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/billpaxton/32/194_2.png) [@billpaxton](https://forums.docker.com/u/billpaxton)\
**Post date:** [October 29, 2014, 8:45pm UTC](https://forums.docker.com/t/how-to-build-docker-image-with-nodejs-app/319/1 "2014-10-29T20:45:02Z")

</div>

Hi guys. I’m trying to basically build my first Docker image which I believe I have successfully accomplished because it gets through all steps without any issues (after much trial and error though).

The problem I’m experiencing though is the fact that within my Docker image, I’m running a NodeJS application. Those of you familiar with NodeJS applications will know that whenever a NodeJS app is started, usually it takes control of the terminal and just sits there saying something along the lines of “Application X is running”. An example of this would be the Ghost blogging NodeJS application.

So what I’m running into is when I’m trying to initially build my image, it never completely builds because it gets to the part where the NodeJS app starts and hangs there saying the app is running. I feel like I’m going about this the wrong way and would just like some guidance into how I can get this image successfully built.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![svendowideit](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/svendowideit/32/119_2.png) [@svendowideit](https://forums.docker.com/u/svendowideit)\
**Post date:** [October 30, 2014, 1:39am UTC](https://forums.docker.com/t/how-to-build-docker-image-with-nodejs-app/319/2 "2014-10-30T01:39:15Z")

</div>

Heya,

sounds like you have it almost right 😄

you don’t want to start your application as a `RUN` statement in the Dockerfile, you want to leave that step for `docker run` - which means either in the Dockerfile `ENTRYPOINT`, or the Dockerfile `CMD`

The Docker users guide is pretty good with giving you all the basics: [http://docs.docker.com/userguide/](http://docs.docker.com/userguide/)

and then the examples, like [http://docs.docker.com/examples/nodejs\_web\_app/](http://docs.docker.com/examples/nodejs_web_app/) can hopefully finish it off 🙂

---

<div class="post-metadata">

**Author:** ![svendowideit](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/svendowideit/32/119_2.png) [@svendowideit](https://forums.docker.com/u/svendowideit)\
**Post date:** [October 30, 2014, 1:40am UTC](https://forums.docker.com/t/how-to-build-docker-image-with-nodejs-app/319/3 "2014-10-30T01:40:58Z")

</div>

mmm, reading that last one, we need to update it to use the `node` image. but the principles still apply

---

<div class="post-metadata">

**Author:** ![billpaxton](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/billpaxton/32/194_2.png) [@billpaxton](https://forums.docker.com/u/billpaxton)\
**Post date:** [October 30, 2014, 1:57am UTC](https://forums.docker.com/t/how-to-build-docker-image-with-nodejs-app/319/4 "2014-10-30T01:57:31Z")

</div>

Hi **sven**! Thanks for your feedback. I actually just ended up using ADD and creating a bash script to perform the “post-install” functions. I hope that’s not considered the lazy way! 😛
