TIL you can make a Dockerfile's FILE dynamic

Oliver Peate posted on May 23rd, 2019

-FROM ruby:2.6-alpine
+ARG FROM_IMAGE=ruby:2.6-alpine
+FROM $FROM_IMAGE

This Dockerfile still defaults to ruby:2.6-alpine after introducing an ARG, but now we can change the FROM image easily:

docker build -t my_project:2.5-latest --build-arg FROM_IMAGE=ruby:2.5-alpine .

Handy for testing libraries against multiple language versions.

What did you learn today?

Write a quick TIL post to reflect on what you've learned.

Write a post