Preparing a Podman Image for Use on NAS Systems

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 Registry

There 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: 

% podman pull docker.io/library/python:latest

You can also find information about how an image was built. For example:

% podman inspect python
or
% podman inspect docker.io/library/python:latest

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:

  • registry.access.redhat.com
  • registry.redhat.io
  • docker.io

For example, to search images related to Python in these three registries, run podman search python:

% podman search python
NAME                               DESCRIPTION
registry.access.redhat.com/        Python 3.3 platform for building and running...
openshift3/python-33-rhel7
...
registry.redhat.io/                Python 3.3 platform for building and running...
openshift3/python-33-rhel7
...
docker.io/library/python           Python is an interpreted, interactive, objec...
...

Then, you can pull one of the images shown in the search results. For example:

% podman pull registry.access.redhat.com/openshift3/python-33-rhel7

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:

% podman pull centos
Resolved "centos" as an alias 
   (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull quay.io/centos/centos:latest...
...
Getting image source signatures
Copying blob 7a0437f04f83 done   | 
Copying config 300e315adb done   | 
Writing manifest to image destination
300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55

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 Containerfile

You 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:

FROM ubuntu:16.04
 
RUN apt update
RUN mkdir -p /usr/local/share/ca-certificates && chown root: \
/usr/local/share/ca-certificates
RUN apt-get install -y ca-certificates
RUN apt-get install -y fortune cowsay lolcat
 
ENV PATH /usr/games:${PATH}
ENV LC_ALL=C
 
ENTRYPOINT fortune | cowsay | lolcat

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 (\).

Examples

Here are a few examples of building a lolcow image from the Containerfile.

Example 1

To build an image of lolcow if this Containerfile is in the current directory:

% podman build .

Example 2

To build an image of lolcow by specifying the location and name of the Containerfile, for example, $HOME/containerfile_test:

% podman build --file $HOME/containerfile_test 
or
% podman build -f $HOME/containerfile_test

Example 3

To build an image from a Containerfile in the current directory and apply a tagged name to the image (for example, lolcow):

% podman build --tag lolcow .
or
% podman build -t 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:

% podman images
REPOSITORY                TAG         IMAGE ID      CREATED         SIZE
localhost/lolcow          latest      76975188c890  22 seconds ago  249 MB
docker.io/library/ubuntu  16.04       b6f507652425  2 years ago     139 MB

When you run a container from the lolcow image, you will see something similar to the following:

% podman run 76975188c890
or
% podman run lolcow
or
% podman run localhost/lolcow

WARN[0000] Failed to mount subscriptions, skipping entry in 
/usr/share/containers/mounts.conf: getting host subscription data: 
failed to read subscriptions from "/usr/share/rhel/secrets": 
open /usr/share/rhel/secrets/redhat.repo: permission denied 
 ________________________________________
/ Q:Why do astronauts use Linux? ? A: Because \
\ they can't open windows in space.                 /
 ----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

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:
% podman tag 67aedfd8c12b lolcow2:24.11

Saving an Existing Image to a Tar File

You can save an existing image to a tar file. For example:

% podman image save -o lolcow.tar 76975188c890
or
% podman image save -o lolcow.tar lolcow 
or
% podman image save -o lolcow.tar localhost/lolcow

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:

% podman load -i lolcow.tar
Getting image source signatures
Copying blob 47ef83afae74 done   | 
....
Writing manifest to image destination
Loaded image: localhost/lolcow:latest

% podman images
REPOSITORY        TAG         IMAGE ID      CREATED         SIZE
localhost/lolcow  latest      76975188c890  10 minutes ago  249 MB

% podman run lolcow
/ Q: What is the sound of one cat \
\ napping? A: Mu.                 /
 ---------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Also read

Contact Us

General User Assistance

Security

  • Report security issues 24x7x365
  • Toll-free: 1-877-NASA-SEC (1-877-627-2732)
  • E-mail: soc@nasa.gov

User Documentation

High-End Computing Capability (HECC) Portfolio Office

NASA High-End Computing Program

Tell Us About It

Our goal is furnish all the information you need to efficiently and effectively use the HECC resources needed for your NASA computational projects.

We welcome your input on features and topics that you would like to see included on this website.

Please send us email with your wish list and other feedback.