Sunday, December 27, 2015

Difference between ARG and ENV in Dockerfile

Starting with Docker 1.9 we have a new feature that I find very useful and necessary - build arguments (see the docker build reference). But docker already has a similar concept - environment variables. So one might be confused (and I certainly was) about the relation of these two.


Actually they have lot in common. Idea for build arguments seems to be created by a several use cases that required passing environment variables to docker at build time. But docker team did not like that idea and decided to create a new concept instead and that is how build arguments were created.

So for me the main distinction between these two concepts are that build arguments are suitable for passing parameters to the dockerfile during a build time. On the other hand, environment variables are something, that you will probably use mainly during runtime (although there are some exceptions but let’s not get into that right now). Another valid use case for environment variables is declaring them inside the Dockerfile. If done like that, all Dockerfiles inheriting from yours can access that value. But there is no way how to change that value during a build time.

6 comments:

  1. thanks for sharing wonderful blog with us. its really more helpful to our institute candidates to get aware some useful knowledge keep sharing more information.
    Dot Net training in Chennai

    ReplyDelete
  2. Great and really helpful article! Adding to the conversation, providing more information, or expressing a new point of view...Nice information and updates. Really i like it and everyday am visiting your site..

    Digital marketing company in Chennai

    ReplyDelete
  3. nice blog i loved exploring it and i do love reading all your posts i will book your sir and share it with others Case Study Solution

    ReplyDelete
  4. Actuary Assignment Help, Actuarial science assignment help in the actuarial field of science from primary to complex level for the understudies of US UK.
    Actuary Assignment Help
    Actuary Finance Assignment Help

    ReplyDelete