Hacker News new | past | comments | ask | show | jobs | submit login

In practice, I find that docker repeats intermediate run steps every time you run docker build.

Which makes sense to me, because you have no idea if an arbitrary shell command is deterministic or not.




a shell command is indeed not really deterministic but docker won't repeat a RUN step as long as it's not preceded by a non-deterministic (for docker) step such as ADD.

So a good way to optimize your Dockerfile is to put commands in an order like:

* dependencies, e.g. apt-get, useradd...

* containers configs PORT, ENV, USER from less likely to change to more likely to change

* ADD commands

* final RUN commands to setup your image




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: