Dockerfile in depth
Table of contents:
Chain RUN instructions
- each RUN command will execute the command on top writable layer of the container, then commit the container as a new image
- the new image is used for the next step in the Dockerfile. So each RUN instructions will create a new image layer
- it is recommended to chain the RUN instructions in the Dockerfile to reduce the number of image layers it creates
Example
Bellow we have a simple Dockerfile. We can modify the Dockerfile:
instead of 4 lines we can agregate lines to get more cosins chain, like:
When building a docker image we have two steps instead of three:
Instructions
Fundamental Instructions:
- FROM
- ARG
Configuration Instructions:
- RUN
- ADD
- COPY
- ENV
Execution Instructions:
- CMD
- ENTRYPOINT
- EXPOSE
Reference:
My site is free of ads and trackers. Was this post helpful to you? Why not
Disqus is great for comments/feedback but I had no idea it came with these gaudy ads.