Your technique is a very good technique, but it needs a further refinement.
Jenkins 2.346.3 is two years old. The Jenkins update center provides plugin version support information for Jenkins releases from the last 12 months. The update center documentation says:
Jenkins weekly and LTS releases up to a year old are supported; anything older will receive update metadata for the oldest supported releases.
Based on that, your container image that represents the current state of your Jenkins controller needs a definition of all the plugins to install and their versions. You can generate that list from “Manage Jenkins” → “Script Console” with the script that is available in “How to report an issue”. That script is:
Jenkins.instance.pluginManager.plugins
.collect()
.sort { it.getShortName() }
.each {
plugin -> println("${plugin.getShortName()}:${plugin.getVersion()}")
}
return
The output of that script can be used in a plugins.txt file or you can list the plugin names and versions on the command line as you’ve done in your example. Refer to “Preinstalling plugins” in the container documentation for more details.