How to specify the "image id" of an existing (local) image in the FROM instruction of a Dockerfile?

As the title says: How can I use a local image, which I just built using the docker build . command, as a base image in my Dockerfile, instead of one from DockerHub? What is the correct syntax?

docker image ls gives:

$ 
REPOSITORY                 TAG       IMAGE ID       CREATED             SIZE
<none>                     <none>    e31fcd5f4da7   25 minutes ago      1.75GB

However, this does not work:

FROM e31fcd5f4da7

Error is:

failed to solve: failed to parse stage name "e31fcd5f4da7": invalid repository name

Prefixing the image id with an @ sign didn’t work either :confused:

Tag the image
docker build -t image:tag .

1 Like

You should build your image with option -t. It allows you to name your image.
After that you can use that name in your Dockerfile

1 Like

Thanks, that worked :+1: