Running files from inside image from host in Jenkins

I actually figured out the solution. In the ImageA pipeline, I added the ‘main.py’ to the artifacts and then in ImageA, I cloned ‘main.py’ and executed it.

ImageA:

always {
        archiveArtifacts artifacts: 'main.py', onlyIfSuccessful: true
    }

Current pipeline:

sh "curl {url to imageA artifact}/main.py -o main.py"
docker.image(ImageA).inside {

    sh "python main.py "

}

By image, I mean the different projects. Not actual images.