I want to make the FROM
instruction in my Dockerfile
dynamic based on an environment variable, so that I can build images based on different versions of a base image without having to change the Dockerfile
itself. Here's an example of what I'm trying to do:
FROM php:${PHP_VERSION}-fpm
In this example, I want to use the PHP_VERSION
environment variable to specify the version of the php image that my image should be based on. However, when I try to build my image using this Dockerfile, I get an error that says:
invalid reference format
Is it possible to use an environment variable in the FROM
instruction of a Dockerfile
? If so, how can I do it?