/sample-docker-arg-env

Showing how Dockerfile ARG ENV and docker build / run works for them

Primary LanguageDockerfile

Showing how Dockerfile ARG ENV works and how docker build / run can override them at Buildtime and Runtime using alpine image

ARG/ENV - Cheatsheet 
Dockerfile 
  ARG key // required @ CLI build
  ARG key=val // default value
  ENV key=val // default value
  ENV key=${key} // def. val. fr. ARG 
Buildtime override ARG
  build --build-arg key=val 
Runtime override ENV 
  run -e "key=val"
  run -e key // host environment 
  run --env-file env.config // file

Docker ARG, ENV and .env - a Complete Guide

https://vsupalov.com/docker-arg-env-variable-guide

Reference

Dockerfile

docker build

  • $ docker build [OPTIONS] PATH | URL | -
  • URL
    e.g. docker build https://github.com/vincenthome/sample-docker-arg-env.git#main (main is the branch name)
  • --build-arg

docker run