Reputation: 157
I am new to docker and kubernetes, so I was reading a pipeline code that pulls a docker image, that will be used as an agent.
pipeline {
agent {
docker {
image 'myinternalrepo/myimage:1.0'
}
in another pipeline it is written in a differnet way, and cant tell what is the difference
pipeline {
agent {
kubernetes{
yaml """
spec:
containers:
- name: myimage
image: myinternalrepo/myimage:1.0
so what is the difference between both? though I am getting the same containers and when running some commands on each container I get same results.
Upvotes: 0
Views: 229
Reputation: 5541
Agent Docker means that your pipeline will be executed inside the docker container running on Docker host. That means that your agent needs to have Docker configured. In other words, it usually means that your agent has the Docker Daemon running.
Agent Kubernetes means that your pipeline will be executed inside the (docker) container running inside Kubernetes Pod in Kubernetes. That means that your agent needs to have (access to) Kubernetes configured.
So, technically, your pipeline will work the same, but the difference is how your Jenkins agents are configured.
For more details, please check https://www.jenkins.io/doc/book/pipeline/syntax/#agent
Upvotes: 0