简体   繁体   中英

Docker Help : Creating Dockerfile and Image for Node.js App

I am new docker and followed the tutorials on docker's website for installing boot2docker locally and building my own images for Node apps using their tutorial ( https://docs.docker.com/examples/nodejs_web_app/ ). I was able to successfully complete this but I have the following questions:

(1) Should I be using these Node Docker images ( https://registry.hub.docker.com/_/node/ ) instead of CentOS6 for the base of my Docker Image? I am guessing the Docker tutorial is out of date?

(2) If I should be basing from the Node Docker Images, does anyone have any thoughts on whether the Slim vs Regular Official Node Image is better to use. I would assume slim would be the best choice but I am confused on why multiple versions exist.

(3) I don't want my Docker Images to include my Node.JS app source files directly in the image and thus have to re-create my images on every commit. Instead I want running my Docker Container to pull the source from my private Git Repository upon starting for a specific commit. Is this possible? Could I use something like entrypoint to specify my credentials and commit when running the Docker Container so it then would run a shell script to pull the code and then start the node app?

(4) I may end up running multiple different Docker Containers on the same EC2 hosts. I imagine making sure the containers are all based off of the same Linux distro would be preferred? This would prohibit me from downloading multiple versions when first starting the instance and running the different containers?

Thanks!

It would have been best to ask 4 separate questions rather than put this all into one question. But:

1) Yes, use the Node image.

2) The "regular" image includes various development libraries that aren't in the slim image. Use the regular image if you need these libraries, otherwise use slim. More information on the libraries is here https://registry.hub.docker.com/_/buildpack-deps/

3) You would probably be better off by putting the code into a data-container that you add to the container with --volumes-from. You can find more information on this technique here: https://docs.docker.com/userguide/dockervolumes/

4) I don't understand this question. Note that amazon now have a container offering: https://aws.amazon.com/ecs/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM