Does Docker EXPOSE make a new layer?

后端 未结 4 1706
时光说笑
时光说笑 2021-02-14 17:07

I have been playing around with creating docker files and reading the documentation and I was wondering this question: Does adding an EXPOSE command to my Doc

4条回答
  •  走了就别回头了
    2021-02-14 17:43

    All instructions create new layers, but instructions that do not change the filesystem will create a layer that is empty.

    It's worth looking into how Docker's filesystem layering works which you can read about here or here for AUFS.

    Essentially new layers on the file system are made of those files that have changed from the layer below them, it's like a stack of diffs. As such, if there is no change, there is no layer to make. Mostly...

    Every instruction in a Dockerfile will create an image layer, but for AUFS (in the case of EXPOSE) that layer will be empty (no difference between it and the one below it).

提交回复
热议问题