1. A method for optimizing a virtual machine (VM) operating system (OS) template, the method comprising: one or more processors obtaining a list of packages in an existing VM template, wherein a VM template is used as a starting point for a VM image build; the one or more processors obtaining a list of packages required to be included in the existing VM template; the one or more processors determining whether the list of packages in the existing VM template includes one or more prerequisite packages required to be included in the existing VM template, wherein a prerequisite package is a package on which one or more packages on the list of packages has a dependency and wherein the prerequisite package is used for updating the existing VM template; responsive to determining the list of packages in the existing VM template does not include one or more prerequisite packages, the one or more processors updating the existing VM template to include the one or more prerequisite packages; and the one or more processors removing one or more packages of the existing VM template that are not included in the list of packages required to be included in the existing VM template from the existing VM template.