Let's break this into 2 stages:
Stage 1 - Image generation & Upload Image
Stage 2 - Create container using newly created image
Stage 1: This can be achieved in many ways:
-
Try to write a shell/python script which would use docker native commands like 'docker build' to generate Image & 'docker push' to push to the registry
-
Try using 'docker.withRegistry' Jenkins scripted directive to create Image & push Image in one step
Stage 2: By default when you try to create the container Docker would download the Image from the specified Docker Registry, so once you have uploaded the image in the previous stage to Registry, use any of your interested steps using docker native cmds or script or pipeline to create the container by specifying the correct Image path i.e
<UR-DOCKER-REGISTRY>/<UR-REPO>/<UR-IMAGE>:<UR-TAG>
and it will download the Image on the machine where u r running it, then the container will run !!