Use Docker Registry Internally ​
This tutorial shows how you can push an image to the Docker Registry and use it.
Prerequsities ​
Steps ​
Create a
simple.pyfile, and paste the following content:pythonimport time import datetime while True: print("Current time:", datetime.datetime.now(), flush=True) time.sleep(10)Create
Dockerfilewith the following content:dockerfileFROM python:3-alpine WORKDIR /usr/src/app COPY simple.py . CMD [ "python", "./simple.py" ]Build and push the image to Docker Registry:
bashdocker build -t simple-image .Import the image to Docker Registry:
bashkyma registry image-import simple-image:latestCreate a Pod using the image from Docker Registry:
bashexport REGISTRY_INTERNAL_PULL_ADDRESS=$(kyma registry config-internal --pull-reg-addr) kubectl run simple-pod --image="${REGISTRY_INTERNAL_PULL_ADDRESS}/simple-image:latest" --overrides='{ "spec": { "imagePullSecrets": [ { "name": "dockerregistry-config" } ] } }'NOTE
An image pull secret with the name
dockerregistry-configis created in every namespace of the cluster.Check if the Pod is running:
bashkubectl get pods simple-podExpected output:
bashNAME READY STATUS RESTARTS AGE simple-pod 1/1 Running 0 60sUse the following command to print the current time every 10 seconds:
bashkubectl logs simple-podExpected output:
bashCurrent 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