Bootstrap FreeKB - OpenShift - Create image using the oc import-image command
OpenShift - Create image using the oc import-image command

Updated:   |  OpenShift articles

An image contains the code used to create a deployment. Then, a deployment can be created from an image, which should then create a replica set (which is the number of pods that should be created), and then the pods should be created.

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

Before importing an image, the oc get images command can be used to determine if the image has already been imported.

~]# oc get images
NAME                                                                      IMAGE REFERENCE
sha256:0089883f8e4387618946cd24378a447b8cf7e5dfaa146b94acab27fc5e170a14   registry.example.com/jboss-webserver-3/webserver30-tomcat8-openshift@sha256:0089883f8e4387618946cd24378a447b8cf7e5dfaa146b94acab27fc5e170a14
sha256:0155e28b6b10d6fba7144df9ce33105acbab32766836baacc67c76b900a58772   registry.example.com/redhat-sso-7/sso70-openshift@sha256:0155e28b6b10d6fba7144df9ce33105acbab32766836baacc67c76b900a58772
sha256:03416282b034b93614ab2af74441ce481226bcf0b0b6c614cacd1b6f008f9792   registry.example.com/jboss-eap-6/eap64-openshift@sha256:03416282b034b93614ab2af74441ce481226bcf0b0b6c614cacd1b6f008f9792
sha256:03795eb1e54f94ffb822b8b3997b5f5bbeaa20bdf7006841864738d1eb58054b   registry.example.com/rhpam-7/rhpam72-businesscentral-openshift@sha256:03795eb1e54f94ffb822b8b3997b5f5bbeaa20bdf7006841864738d1eb58054b

 

The oc import-image command can be used to import an image from an external registry, such as registry.redhat.io, registry.access.redhat.com, registry.ci.openshift.org, and the list goes on. In this example, an image named openjdk18 is imported.

~]$ oc import-image openjdk18 --from=registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift --confirm
imagestream.image.openshift.io/openjdk18 imported

 

If the image is stored in a secured external registry, you may need to use the podman login command to log into the external registry.

sudo podman login registry.redhat.io

 

And then use the podman pull command to pull the image from the external registry.

sudo podman pull registry.redhat.io/openshift4/ose-hello-openshift-rhel8:v4.7.0-202205312157.p0.g7706ed4.assembly.stream

 

Now the oc get images command should include the imported image.

~]$ oc get images
NAME                                                                      IMAGE REFERENCE
sha256:6f75262945716ac8f9bdcf1c26ba2eb962764f0e89ba1745933be553a6b58aa4   registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift@sha256:6f75262945716ac8f9bdcf1c26ba2eb962764f0e89ba1745933be553a6b58aa4

 

And the oc get imagestreams command should also include the imported image.

~]$ oc get imagestream openjdk18
NAME        IMAGE REPOSITORY                                                 TAGS     UPDATED
openjdk18   image-registry.openshift-image-registry.svc:5000/foo/openjdk18   latest   15 hours ago

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 0b43c2 in the box below so that we can be sure you are a human.