Use ARG before FROM.

Dockerfile:

1
2
1: ARG tag
2: FROM ANY_IMAGE:$tag

And docker build with args.

1
docker build . -t desktop --build-arg tag=hoge

You can build a container FROM ANY_IMAGE:hoge.

Bibliography