How to set image name in Dockerfile?

Better Stack Team
Updated on April 7, 2023

You can set the image name in a Dockerfile using the FROM instruction. The FROM instruction specifies the base image that your Docker image will be built upon.

The basic syntax of the FROM instruction is:

FROM image:tag
  • image: The name of the base image you want to use.
  • tag: The tag of the base image you want to use.

For example, to set the image name to my-image in your Dockerfile, you can use the following FROM instruction:

FROM my-registry/my-image:latest

In this example, my-registry is the hostname of the private registry, my-image is the name of the image, and latest is the tag of the image.

When you build the Docker image using this Dockerfile, the resulting Docker image will have the name my-registry/my-image:latest. You can then push this image to your Docker registry or use it locally on your machine.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →

Reliability is the
ultimate feature

Delightful observability tools that turn your logs & monitoring into a secret weapon for shipping better software faster.

Explore Better Stack