search

Home  >  Q&A  >  body text

前端 - 如何正确的使用 docker 来运行 webdev?

后端的 php nginx 服务都跑在 docker 上

现在我想把前端的构建工具也跑在 docker 上,例如 node gulp 等等

应该怎么处理这个工作流,单独新建一个容器吗?如果有多个项目,应该如何操作?

仅有的幸福仅有的幸福2771 days ago825

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-04-24 16:01:02

    This Case....
    There are a thousand docker environments in the eyes of a thousand people.
    It depends on how you set up the network and how you coordinate the application.

    1. Personally, I am used to treating Docker as a process, so I will try my best to only suspend one process per container instance, because I personally think that if n applications are running in a container, then the container is not at the process level. It’s at the OS/machine level, so if you’ve already built a virtual machine image, why do you still need a docker image? . Even with the cooperation of php and nginx, there will be two containers. It can be regarded as one application. Then for other languages, such as other applications you use nodejs to implement, I will definitely run another container instance, and then Run nginx to replace these two. So I want to ask if your nginx+php docker is a container?
    2. It is also possible to mix multiple processes in one docker. After all, it is based on the operating system From [OS]. You can run a process monitor like supervisor (python) in docker and hand supervisor to docker to suspend. Isn’t there pm2 (nodejs) for the same application?
    Such a dockerfile is not easy to write anyway.
    3. Mixed. I feel that the best way is to look at the specific business scenarios and the architecture. We need to use limited resources to complete the business to the greatest extent.
    It is recommended to first take a look at the advantages brought by docker and the price you need to pay for these advantages so that you can make better decisions. Otherwise, it is better not to use it indiscriminately.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-24 16:01:02

    Of course, a new node container is pulled up and run. The so-called container does not mean that it values ​​the benefits of light weight and low coupling. In order to achieve loose coupling, generally the database and server will be run in two containers, and the ports will be mapped. If done well, even each docker can be regarded as an nb process that can run various service applications without taking up too many resources. This is also the meaning of docker. It is easy to transplant, small in size and loosely coupled.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-04-24 16:01:02

    The front end is nothing more than node gulp webpack yarn sass waiting

    There is a ready-made web-dev-docker here. I think you can refer to it or use it directly.

    reply
    0
  • Cancelreply