search

Home  >  Q&A  >  body text

制作dockerfile的流程

最近看了一些Docker相关的知识,对制作dockerfile的流程有一些不明白的地方。

假如要制作一个基于Ubuntu的包含Nginx、MySQL、PHP等服务的dockerfile,我现在的流程是:

等于说是先把流程跑一遍,记录下所有执行的命令,然后再把这些步骤复制到dockerfile里。

个人感觉这样做是不对的,请问大家都是怎么做的??

阿神阿神2830 days ago823

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-25 09:05:37

    That’s right. If you are very familiar with all the processes, you can naturally write the Dockerfile directly. However, there is basically no absolute guarantee for this kind of thing. In particular, most of Docker’s basic system images are very streamlined, and some software dependency packages need to be downloaded and installed. Therefore, although the process of building a container by yourself is a bit time-consuming, it is relatively short. On the contrary, it will save time than dreaming about writing Dockerfile.

    Usually writing a Dockerfile is a process like this:

    1. Preview the installation process through the container and record the build commands

    2. Summarize and optimize installation commands, and write Dockerfile

    3. Try to use Dockerfile to build the image and check if there are any problems

    4. Create a container through the built image to ensure that the program in it can be used correctly

    reply
    0
  • 習慣沉默

    習慣沉默2017-04-25 09:05:37

    By referring to the ready-made dockerfile on docker hub and modifying it according to your own needs, it will be more efficient. To write the dockerfile from scratch, you can only do it like the brothers above. I call it the "video recorder" method.

    reply
    0
  • Cancelreply