简体   繁体   English

Docker帮助:为Node.js App创建Dockerfile和Image

[英]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/ ). 我是新的docker并按照docker网站上的教程在本地安装boot2docker,并使用他们的教程( https://docs.docker.com/examples/nodejs_web_app/ )为Node应用程序构建我自己的图像。 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? (1)我应该使用这些Node Docker映像( https://registry.hub.docker.com/_/node/ )而不是CentOS6作为我的Docker映像的基础吗? I am guessing the Docker tutorial is out of date? 我猜Docker教程已经过时了?

(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. (2)如果我应该基于Node Docker Images,那么有没有人想过Slim vs Regular官方节点图像是否更好用。 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. (3)我不希望我的Docker Images直接在图像中包含我的Node.JS应用程序源文件,因此必须在每次提交时重新创建我的图像。 Instead I want running my Docker Container to pull the source from my private Git Repository upon starting for a specific commit. 相反,我希望在启动特定提交时运行我的Docker容器从我的私有Git存储库中提取源。 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? 我可以使用像入口点这样的东西来指定我的凭据并在运行Docker Container时提交,然后它会运行一个shell脚本来提取代码,然后启动节点应用程序吗?

(4) I may end up running multiple different Docker Containers on the same EC2 hosts. (4)我最终可能会在同一个EC2主机上运行多个不同的Docker容器。 I imagine making sure the containers are all based off of the same Linux distro would be preferred? 我想要确保容器都是基于同一个Linux发行版的首选? 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. 1)是,使用节点图像。

2) The "regular" image includes various development libraries that aren't in the slim image. 2)“常规”图像包括不在细长图像中的各种开发库。 Use the regular image if you need these libraries, otherwise use slim. 如果需要这些库,请使用常规图像,否则请使用slim。 More information on the libraries is here https://registry.hub.docker.com/_/buildpack-deps/ 有关这些库的更多信息,请访问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. 3)通过将代码放入使用--volumes-from添加到容器的数据容器中,可能会更好。 You can find more information on this technique here: https://docs.docker.com/userguide/dockervolumes/ 您可以在此处找到有关此技术的更多信息: https//docs.docker.com/userguide/dockervolumes/

4) I don't understand this question. 4)我不明白这个问题。 Note that amazon now have a container offering: https://aws.amazon.com/ecs/ 请注意,亚马逊现在有一个容器提供: https//aws.amazon.com/ecs/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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