Question: Given a tag of an image on dockerhub such as ubuntu:22.04
what cli command determines the SHA-256 that can be used instead of the tag in a FROM instruction in a Dockerfile?
I have tried docker images ubuntu:22.04 --format "{{.ID}}" --no-trunc
but that does not produce an ID that works, more context on what I am trying todo below.
I have docker file that looks like this
FROM ubuntu:22.04
RUN apt-get update -y \
&& apt-get install -y jq git curl
I would like to resolve the id of the tag 22.04
tag using a command line so I can write a docker file that looks something like
ARG ID
FROM ubuntu@$ID
RUN apt-get update -y \
&& apt-get install -y jq git curl
with the goal of being able to set the id arg from the CLI with the command
docker build . \
--tag shell \
--build-arg ID=$(docker images ubuntu:22.04 --format "{{.ID}}" --no-trunc)
the above command errors out with output below
[+] Building 0.1s (3/3) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 36B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> ERROR [internal] load metadata for docker.io/library/ubuntu@sha256:df5de72bdb3b711aba4eca685b1f42c722cc8a1837ed3fbd548a9282af2d836d 0.0s
------
> [internal] load metadata for docker.io/library/ubuntu@sha256:df5de72bdb3b711aba4eca685b1f42c722cc8a1837ed3fbd548a9282af2d836d:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: encountered unknown type ; children may not be fetched
when I run docker images ubuntu:22.04 --format "{{.ID}}" --no-trunc
I get
sha256:df5de72bdb3b711aba4eca685b1f42c722cc8a1837ed3fbd548a9282af2d836d
as the
output
Question: Given a tag of a container on dockerhub what cli command determines the SHA-256 that can be used instead of the tag in a FROM instruction in a Dockerfile?