How do I use docker image to create a container in Jenkins to compile github repo code?

Jenkins runs on the server. What I want is that every time push commit comes to this github repo, Jenkins uses a docker image to create container to compile the entire project. How do you do that? This project is so big that it is impossible to create a new container every time and then put the code in it and compile it. Is there any good idea? Can I use Jenkins pipline to do this?

Mar.28,2021
Menu