Is it possible to run a docker image from a Tekton task? A majority of examples I have seen have to do with building and deploying Docker Images with Tekton, but nothing on how to run an already built image.
I am using a cron job to trigger a Tekton EventListener which then runs a Taskrun. I want the task to run a docker image hosted on a private docker repo. The Taskrun refers to this Task.
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: update-ip
spec:
steps:
- name: update-ip
image: [<private-docker-repo>]
command: ["docker"]
args: ["run", <private-docker-repo/path-to-image>]
Here is an example of common tutorials i see
any help would be appreciated
2
Answers
Your are looking for DinD ( Docker In Docker) feature with tekton:
This is a complete example, and it should answer your need:
focus on the sidecar section (L42 -> L66) where the dind container is added.
The "task" of each Tekton task is to run a container (image). So, it will be sufficient to state your container image, and that’s it.
Your example should look like
command
andargs
are optional, if you want to execute something else than the ENTRYPOINT and/or CMD, that is defined by your container image.For even more flexibility, you can alternatively state a
script
, which allows to execute several commands within your container, like a shell script.Hints:
tekton.dev/v1beta1
.