Skip to content

Latest commit

 

History

History
80 lines (54 loc) · 1.65 KB

01-10-use-registry-internally.md

File metadata and controls

80 lines (54 loc) · 1.65 KB

Use Docker Registry Internally

This tutorial shows how you can push an image to the Docker Registry and use it.

Prerequsities

Steps

  1. Create a simple.py file, and paste the following content:

    import time
    import datetime
     
    while True:
      print("Current time:", datetime.datetime.now(), flush=True)
      time.sleep(10)
  2. Create Dockerfile with the following content:

    FROM python:3-alpine
    
    WORKDIR /usr/src/app
    
    COPY simple.py .
    
    CMD [ "python", "./simple.py" ]
  3. Build and push the image to Docker Registry:

    docker build -t simple-image .
  4. Import the image to Docker Registry:

    kyma image-import simple-image:latest
  5. Create a Pod using the image from Docker Registry:

    kubectl run simple-pod --image=localhost:32137/simple-image:latest --overrides='{ "spec": { "imagePullSecrets": [ { "name": "dockerregistry-config" } ] } }'
  6. Check if the Pod is running:

    kubectl get pods simple-pod

    Expected output:

    NAME         READY   STATUS    RESTARTS   AGE
    simple-pod   1/1     Running   0          60s
  7. Use the following command to print the current time every 10 seconds:

    kubectl logs simple-pod

    Expected output:

    Current time: 2024-05-17 11:23:34.957406
    Current time: 2024-05-17 11:23:44.954583
    Current time: 2024-05-17 11:23:54.956107
    Current time: 2024-05-17 11:24:04.966306