|
Article ID: 697
Last updated: 20 Mar, 2025
This article describes several ways of getting an image ready to use on NAS systems: pulling a pre-built image from a registry; building an image with a containerfile; and saving an image to a tar file. Note: Pulling or building an image that requires internet access can only be done on a NAS front-end node. Pulling a Pre-Built Image From a RegistryThere are many publicly available registries that host pre-built images. You can pull an image from a registry using its fully qualified image name including the registry server, namespace, image name, and tag. For example:
You can also find information about how an image was built. For example:
At NAS, the file /etc/containers/registries.conf includes a list of registries where you can search for images by using the podman search command:
For example, to search images related to Python in these three registries, run podman search python:
Then, you can pull one of the images shown in the search results. For example:
Note: The two Red Hat registries (registry.access.redhat.com and registry.redhat.io) hold essentially the same container images. However, some images in registry.redhat.io require an active Red Hat account; these are only available in that registry. In addition, a few files under /etc/containers/registries.conf.d define short names for some images (mostly OS-related short names). For example, there is an entry "centos" = "quay.io/centos/centos" in the file 000-shortnames.cong. Therefore, the following command will pull the image centos from quay.io:
Note: By default, the podman pull command will pull an image with the architecture according to the host machine on which this command is run (for example, amd64). To explicitly specify an architecture, add the --arch option (for example, --arch=arm64). Keep in mind that an image with amd64 architecture most likely will not run on a host of arm64 architecture, and vice versa. To learn more, see this Red Hat blog post. Building an Image With a ContainerfileYou can build an image from scratch using a Containerfile, which is a configuration file that automates the process of creating an image. It uses the same syntax as a Dockerfile. By default, to build an image, Podman looks for a file named Containerfile. It will fall back to Dockerfile if Containerfile does not exist. You can also explicitly specify the name of a Containerfile or Dockerfile, as shown in an example below. Note: Images and containers are stored under /nasa2/your_nas_username/containers/storage. For instructions on creating a Containerfile, read man containerfile (or this ubuntu man page). Here is a Containerfile, modified from an example downloaded from GitHub, for building an image of lolcow:
Note: A command line in the code box above is too long to be formatted as one line, so it is broken with a backslash (\). ExamplesHere are a few examples of building a lolcow image from the Containerfile. Example 1To build an image of lolcow if this Containerfile is in the current directory:
Example 2To build an image of lolcow by specifying the location and name of the Containerfile, for example, $HOME/containerfile_test:
Example 3To build an image from a Containerfile in the current directory and apply a tagged name to the image (for example, lolcow):
If this image is successfully built, you will see it as "localhost/lolcow" under the REPOSITORY column when you run the podman images command. For example:
When you run a container from the lolcow image, you will see something similar to the following:
Note: Ignore the warning message. TIP: When building an image without a tag, the image is identifiable only by its imageID. However, you can add a tag to an existing untagged image using the podman tag command. For example:
Saving an Existing Image to a Tar FileYou can save an existing image to a tar file. For example:
The tar file lolcow.tar will be saved in the directory the above command was run. If the image is removed, and later you want to load it from the tar file, do:
Also read
|