'run both master & slaves as docker containers "Jobs"

I have Jenkins Master runnig on docker conatiner and Every time I need A slave to run my jobs a docker container spins up as a Jenkins slave and my script is executed on the slave and after the execution is completed the container is destroyed.

Is there is possiblibily to run both master & slaves as docker containers using docker-compose or kubernetes or docker ssh protocol .



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source