Categories
Uncategorized

Pushing an external and not yet published Docker image into Red Hat OpenShift V3

If you should have followed my previous postings ( thanks for that!! ), then you should have read my blog IMPORTING AN EXTERNAL AND NOT YET PUBLISHED DOCKER IMAGE INTO RED HAT OPENSHIFT V3, in which I have explained how to manually carry a Docker image from a non OpenShift build-server to our OpenShift infrastructure.

This time we want to reduce the effort and push our image directly from our build-server to OpenShift.

As it is recommended to only expose a secured OpenShift registry for remote access, we have to secure our registry.

Now let’s walk through the steps to push an existing image to our OpenShift V3 infrastructure.

Step 1 – To be performed on the OpenShift Master

Login to OpenShift via a console

# oc login
 Username: psteiner

When doing a push into a registry, OpenShifts expects the responding project to be already existing. So we need to create it first, or change into it, if it already exists

[psteiner@master certs.d]$ oc new-project iotdemo
Now using project "iotdemo" on server "https://master.example.com:8443".

Step 2 – To be performed on the OpenShift Master

Get your user-token and remember it for later steps

# oc whoami -t
 OI6I1JnQDOD-Dnmxtiysi0pnes2Eo4thMQxhxuwxgws

Step 3 – To be performed on the build-server

Identify the image, which you want to push to OpenShift

$ docker images 
REPOSITORY                    TAG    IMAGE ID     CREATED       VIRTUAL SIZE 
iotdemofuse_iotcontrollercep  latest c2471ec2cabc 22 hours ago  3.203 GB

Tag it with the right URL for the OpenShift registry

$ docker tag iotdemofuse_iotcontrollerreceiver registry.cloudapps.example.com/iotdemo/iotcontrollerreceiver

Lets’s analyse this command

$ docker tag iotdemofuse_iotcontrollerreceiver(1) registry.cloudapps.example.com(2)/iotdemo(3)/iotcontrollerreceiver(4)

 

  1. the local name of the image
  2. the URL of our remote OpenShift registry
  3. the name of the target project on the OpenShift server, as created in step 1
  4. the name of the image on the OpenShift

Step 4 – To be performed on the build-server

Login to the remote OpenShift registry. Please use the token, which you retrieved in step 2

$ docker login -u psteiner -e psteiner@redhat.com -p OI6I1JnQDOD-Dnmxtiysi0pnes2Eo4thMQxhxuwxgws registry.cloudapps.example.com 
WARNING: login credentials saved in /home/psteiner/.docker/config.json 
Login Succeeded

Again, let’s analyse this command

$ docker login -u psteiner (1) -e psteiner@redhat.com (2) -p OI6I1JnQDOD-Dnmxtiysi0pnes2Eo4thMQxhxuwxgws (3) registry.cloudapps.example.com (4)
  1. your userID on OpenShift
  2. some eMail-Address
  3. the token, as retrieved in step 2
  4. the URL of the OpenShift registry

Step 5 – To be performed on the build-server

Push the tagged image to OpenShift and use tag-value from step 3

$ docker push registry.cloudapps.example.com/iotdemo/iotcontrollerreceiver
The push refers to a repository [registry.cloudapps.example.com/iotdemo/iotcontrollerreceiver] (len: 1) 
4a1a9f0d3283: Image already exists 
47d44cb6f252: Image already exists 
Digest: sha256:d0a456315e44ebab465b04eaa8021f16472b494a290c035e78c07caa4300abc4

Step 6 – To be performed on the OpenShift Master

To verify a successful push of the image onto the OpenShift registry, we only need to check for the automatically created image-stream.

$ oc get is
NAME DOCKER REPO TAGS UPDATED
iotcontrollerreceiver 172.30.80.73:5000/iotdemo/iotcontrollerreceiver latest 8 minutes ago

All done! You have successfully pushed your image from a non-OpenShift build-server to your OpenShift system.

 

 

Leave a Reply

%d bloggers like this:
close

Subscribe to our newsletter.

Please select all the ways you would like to hear from Open Sourcerers:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our newsletter platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.