DEV Community

Cover image for Whats the difference between Args and Env in Docker
Mohamad Lawand
Mohamad Lawand

Posted on

1

Whats the difference between Args and Env in Docker

In this article we are going to discuss what's the difference between Args and Env within docker

You can watch the full video on YouTube

You can find the source code on github:
https://github.com/mohamadlawand087/v5-dockerComposeAspNetCpre

When you are creating your docker file to containerise your application often you want to pass arguments to your docker image and to your container but this can get a bit confusing if you are just starting out with Docker and containerisation.

Let us see how we can break this down

ARG - Build time var

Passing arguments to our docker image at build time we utilise ARG. ARG is only available during the build of a docker image. Once the image is build we cannot utilise ARG.

When utilising ARG it is advisable not to pass sensitive data as by using the following command

docker history
Enter fullscreen mode Exit fullscreen mode

We can see the args that was passed to build the image

ENV - All around Var

Unlike the ARG var, ENV is available to both the container and the image. The ENV can be overriden while starting a container

Image description

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more