How to use cached Docker images in a Jenkins slave?

477 views
Skip to first unread message

ZillaYT

unread,
Apr 5, 2019, 10:59:22 AM4/5/19
to Jenkins Users
We have a number of EC2 instances that we create in our AWS ECS cluster, which run Docker. One of the EC2 instances run the Jenkins master, and the others are designated as slaves.

So what we do is for every job, we run a Docker container in one of these slave EC2 instances. We set up, in the Cloud portion of Jenkins configuration page, a label called 'linux-fargate' that has the task definition and the Docker image that we want to run.

All is working well, that is, we are able to run a Docker container for each job using the task definition and Docker image we set up in the configuration page.

However, we pull the image from our ECR repo "every time" and this takes a long time. How can we tell Jenkins to use the image that's already on the EC2 instance instead of pulling the image every time?

Thanks,
Chris

Ivan Fernandez Calvo

unread,
Apr 5, 2019, 2:21:10 PM4/5/19
to Jenkins Users
We have a similar problem, to make a local cache of those images we pull then when we build packer images (once a day) so when we spin our VMs they have those Docker images and don't have to pull them from any repository. The only disadvantage of that it is you need extra disk space. In your case, you can do the same if you build your own AMIs

ZillaYT

unread,
Apr 16, 2019, 11:14:05 AM4/16/19
to Jenkins Users
So what values do you put in your cloud section of you Jenkins config page for the 'Task definition' and 'Docker image' fields?

Screen Shot 2019-04-16 at 11.05.13 AM.png

kuisathaverat

unread,
Apr 16, 2019, 11:30:11 AM4/16/19
to jenkins...@googlegroups.com
You do not need to change anything there, you would need custom ECS AMIs where you have pre-pull the Docker images that you will need, see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/SVfcJO7KB-g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/502186ce-4ddf-402e-9a64-13e28ee29612%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

ZillaYT

unread,
Apr 16, 2019, 12:26:23 PM4/16/19
to Jenkins Users
Yeah we build our own AMIs via Packer. I'll looking into pulling the images into it. Thanks.

Chris


On Tuesday, April 16, 2019 at 11:30:11 AM UTC-4, kuisathaverat wrote:
You do not need to change anything there, you would need custom ECS AMIs where you have pre-pull the Docker images that you will need, see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html

El mar., 16 abr. 2019 a las 17:14, ZillaYT (<zil...@gmail.com>) escribió:
So what values do you put in your cloud section of you Jenkins config page for the 'Task definition' and 'Docker image' fields?

Screen Shot 2019-04-16 at 11.05.13 AM.png





On Friday, April 5, 2019 at 2:21:10 PM UTC-4, Ivan Fernandez Calvo wrote:
We have a similar problem, to make a local cache of those images we pull then when we build packer images (once a day) so when we spin our VMs they have those Docker images and don't have to pull them from any repository. The only disadvantage of that it is you need extra disk space. In your case, you can do the same if you build your own AMIs

El viernes, 5 de abril de 2019, 16:59:22 (UTC+2), ZillaYT escribió:
We have a number of EC2 instances that we create in our AWS ECS cluster, which run Docker. One of the EC2 instances run the Jenkins master, and the others are designated as slaves.

So what we do is for every job, we run a Docker container in one of these slave EC2 instances. We set up, in the Cloud portion of Jenkins configuration page, a label called 'linux-fargate' that has the task definition and the Docker image that we want to run.

All is working well, that is, we are able to run a Docker container for each job using the task definition and Docker image we set up in the configuration page.

However, we pull the image from our ECR repo "every time" and this takes a long time. How can we tell Jenkins to use the image that's already on the EC2 instance instead of pulling the image every time?

Thanks,
Chris

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/SVfcJO7KB-g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkins...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages