Importing an external Docker Image into Red Hat OpenShift repository.

I already created some Images on the last posts. So, You can check the Openshift installation and How to create docker image first begin.

The image which I want to us is on a different system, which is in no way connected to my OpenShift environment. Therefore saving the image into a file is the first thing to do:

# docker save -o tomcat cloudroot/tomcat
# ls -ltr
total 181152
-rw------- 1 adilsoncesar staff 92749312 May 17 18:54 tomcat

After copying the file to the OpenShift server, you can load it into the local Docker repository.

# docker load -i tomcat
e154057080f4: Loading layer [=================>] 4.23 MB/4.23 MB
116a9ae57282: Loading layer [=================>] 79.26 MB/79.26 MB
41c777dcbbfb: Loading layer [=================>] 9.244 MB/9.244 MB
Loaded image: cloudroot/tomcat:latest
#

That case, we are able to import docker image to Openshift repository.

# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cloudroot/tomcat latest 41ad78487035 2 days ago 91.5 MB

Before we continue, lets login on OpenShift.

# oc login
Authentication required for https://192.168.1.100:8443 (openshift)
Username: admin
Password:
Login successful.
You have one project on this server: "cloudroot"
Using project "cloudroot".
[root@centos tmp]#

At this point we can also login to our OpenShift registry. To do so, first we need to get the token for our user

# oc whoami -t 
F5z2sAtOKvqPQMk_Vd8Sli_S47fldU5w1nkS0NPHQ

and use the token for the login to the registry.

# docker login -u admin -p F5z2sAtOKvqPQMk_Vd8Sli_S47fldU5w1nkS0NPHQ 172.30.1.1:5000
Login Succeeded
#
*The IP-Address at the end of the command is for our OpenShift registry and port.

Now we need to put a Tag to our local image.

# docker tag cloudroot/tomcat 172.30.1.1:5000/cloudroot/tomcat

The last step is the push itself

# docker push 172.30.1.1:5000/cloudroot/tomcat
The push refers to a repository [172.30.1.1:5000/cloudroot/tomcat]
41c777dcbbfb: Pushed
116a9ae57282: Pushed
e154057080f4: Pushed
latest: digest: sha256:f4d872609292f7887de81d182262b06c size: 9409
#

Running the command will verify the "image stream" into Openshift repository.

# oc get is
NAME DOCKER REPO TAGS UPDATED
tomcat 172.30.1.1:5000/cloudroot/tomcat latest 41 seconds ago

or via Web console.

Now you are ready to use the ImageStream.

Enjoy! :)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.