I realized that I could check it myself. and I found that adding EXPOSE does not add a new level to the file system, but it does add a level nonetheless, it does matter what order you make with your docker files for your cache levels.
basically: each command creates a new level, each command that changes the file system creates a file system level.
FROM ... EXPOSE 80 COPY smthing .
differs from:
FROM ... COPY smthing . EXPOSE 80
It is executed several times (say, in a development environment).
in the first example, the EXPOSE
command is cached and not executed, even if the smthing
file changes. If any file changes, docker build
will only re-execute this command (rest is taken from the cache).
In the second example. if the smthing
file changes, the EXPOSE command will also be rebuilt. (since everything after the copy command is invalid and re-runs on docker build
).
I would change the EXPOSE port, the first case would be to re-execute the copy command, where the second example would not be.
But both of them will lead to the same file system file of the final result.
docker inspect imageName
source share