Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dynamic image resolution in docker multi stage builds

Is it possible to have a dynamic image resolution in docker for multistage builds?

The following works

ARG node_version=10-alpine

FROM node:${node_version} as stage1

but the following

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

FROM ubuntu as dbdump

ARG node_version=10-alpine

FROM node:${node_version} as stage1

fails with the error

Dockerfile:5
--------------------
   3 |     ARG node_version=10-alpine
   4 |
   5 | >>> FROM node:${node_version} as stage1
   6 |
   7 |
--------------------
ERROR: failed to solve: failed to parse stage name "node:": invalid reference format

>Solution :

Any ARGs that get used in FROM lines need to be declared before the very first FROM line. Anything that’s after a FROM line is specific to that build stage.

ARG node_version=10-alpine

FROM ubuntu as dbdump
...

FROM node:${node_version} as stage1
...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading