Docker build images

Resources

Building images without compose

In kubernetes iamges are used directly w/o docker compose. Hence, building is to rely on Dockerfile and build context exclusively.

This affects two aspects:

  • environmental variables are set via --build-arg switches for each variable. If not values are supplied, value from shell environment that runs docker-build is taken
  • Dockerfile must be set explicitly on the command line via -f flag.
  • The last argument is the context where additional files required to build the image reside

In total:

export ARG1=SOME_VALUE
export ARG2=OTHER_VALUE
#take . as the context
docker build --build-arg ARG1 --build-arg ARG2 -f /path/to/dockerfile .

Discussion