Use ARG before FROM.

Dockerfile:

1: ARG tag
2: FROM ANY_IMAGE:$tag

And docker build with args.

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

You can build a container FROM ANY_IMAGE:hoge.

Bibliography