Create a Custom Image

<p>This article uses the creation of a Linux custom image on the Windows platform as an example.</p> <p><strong>Procedures</strong></p> <p>1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Make a json file that meets your requirements according to the various fields introduced above.</p> <p>2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Execute the command packer build xxx.json to create a custom image.</p> <p>3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The sample operation results are as follows, the following example will create a custom image with Redis.</p> <pre> <code>PS C:\ &gt; .\packer.exe build "C:\HKA_LINUX.json" pacloud output will be in this color. ==&gt; pacloud: zone_name:[HKA] url:[https://api.yun.pingan.com/api/v1] timeout:[10] image_name:[linux-test] source_image_id:[Image-2N5XOLDfUb] vm_password:[xxxxxxxx] cleanup_nat:[false] cpu_amount:[0] memory_size_mb:[0] ==&gt; pacloud: Start to configure the network ... ==&gt; pacloud: Start to find or create VPC .. ==&gt; pacloud: Found an existing VPC, name: HKX17011 ==&gt; pacloud: Start to find or create Network .. VPC ID: Vpc-5x2Epc0ism ==&gt; pacloud: Found an existing Network, name: HKX17011DMZ ==&gt; pacloud: Start to find or create Subnet.. ==&gt; pacloud: Found an existing Subnet, name: HKX17011DMZHKA001 ==&gt; pacloud: Start to configure the NAT ... ==&gt; pacloud: Get NAT type ... ==&gt; pacloud: NAT type successfully obtained, name: [by hour] Start to search or create NAT ... ==&gt; pacloud: After searching or creating NAT ==&gt; pacloud: NAT ID:Nat-yy9YwG6Bke ==&gt; pacloud: Start creating bandwidth package, getting bandwidth package type ... ==&gt; pacloud: The bandwidth package type is successfully obtained. Name: Start to obtain the operator list by hour ... ==&gt; pacloud: The operator of the bandwidth package is successfully obtained. The name: HGC begins to create a bandwidth package ... ==&gt; pacloud: The bandwidth package order is successfully created, and the order ID: Order-h1AwztRZTY starts to wait for the order status to be completed ... ==&gt; pacloud: The bandwidth package order has been implemented, and the bandwidth package name: NAT-BW-X1700034 begins to obtain the bandwidth package details ... ==&gt; pacloud: The bandwidth package details are obtained and successfully created. Start to create NAT IP ... ==&gt; pacloud: The asynchronous task is created successfully, waiting for completion ... ==&gt; pacloud: The NAT IP has been created. If you fail to obtain the details, you need to delete it manually ==&gt; pacloud: NAT IP details obtained successfully, name: NAT-BW-IPX1700067 ==&gt; pacloud: NAT configuration completed ==&gt; pacloud: Start to configure the security group ==&gt; pacloud: The security group is configured ==&gt; pacloud: Start to create ECS ... ==&gt; pacloud: The ECS has been successfully created. Name: HKA-LX1700149 ==&gt; pacloud: Successfully obtained ECS details, ECS created ==&gt; pacloud: Start to configure DNAT Rule ==&gt; pacloud: DNAT Rule configuration completed ==&gt; pacloud: Start adding ECS to security group ... ==&gt; pacloud: Successfully added ECS to the security group ==&gt; pacloud: Using ssh communicator to connect: 118.143.215.231 ==&gt; pacloud: Waiting for SSH to become available... ==&gt; pacloud: Connected to SSH! ==&gt; pacloud: Provisioning with shell script: C:\Users\ADMINI~1\AppData\Local\Temp\2\packer-shell686277403     pacloud: Loaded plugins: fastestmirror     pacloud: Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast     pacloud: Determining fastest mirrors     pacloud: Resolving Dependencies     pacloud: --&gt; Running transaction check     pacloud: ---&gt; Package redis.x86_64 0:3.2.12-2.el7 will be installed     pacloud: --&gt; Processing Dependency: libjemalloc.so.1()(64bit) for package: redis-3.2.12-2.el7.x86_64     pacloud: --&gt; Running transaction check     pacloud: ---&gt; Package jemalloc.x86_64 0:3.6.0-1.el7 will be installed     pacloud: --&gt; Finished Dependency Resolution     pacloud:     pacloud: Dependencies Resolved     pacloud:     pacloud: ================================================================================     pacloud: Package           Arch            Version                  Repository     Size     pacloud: ================================================================================     pacloud: Installing:     pacloud: redis             x86_64          3.2.12-2.el7             epel          544 k     pacloud: Installing for dependencies:     pacloud: jemalloc          x86_64          3.6.0-1.el7              epel          105 k     pacloud:     pacloud: Transaction Summary     pacloud: ================================================================================     pacloud: Install  1 Package (+1 Dependent package)     pacloud:     pacloud: Total download size: 648 k     pacloud: Installed size: 1.7 M     pacloud: Downloading packages:     pacloud: --------------------------------------------------------------------------------     pacloud: Total                                              953 kB/s | 648 kB  00:00     pacloud: Running transaction check     pacloud: Running transaction test     pacloud: Transaction test succeeded     pacloud: Running transaction     pacloud: Installing : jemalloc-3.6.0-1.el7.x86_64                                  1/2     pacloud: Installing : redis-3.2.12-2.el7.x86_64                                    2/2     pacloud: Verifying  : redis-3.2.12-2.el7.x86_64                                    1/2     pacloud: Verifying  : jemalloc-3.6.0-1.el7.x86_64                                  2/2     pacloud:     pacloud: Installed:     pacloud: redis.x86_64 0:3.2.12-2.el7     pacloud:     pacloud: Dependency Installed:     pacloud: jemalloc.x86_64 0:3.6.0-1.el7     pacloud:     pacloud: Complete! ==&gt; pacloud: Start to close ECS ==&gt; pacloud: ECS shutdown completed ==&gt; pacloud: Start to create image ==&gt; pacloud: Successfully created, image ID: Image-WB9sKza3Jj ==&gt; pacloud: Start to move the ECS out of the security group. If it fails, please move out manually ==&gt; pacloud: Move out successfully ==&gt; pacloud: Start to clean up the DNAT rules, please delete manually if the deletion fails. DNAT Rule ID: NatDnatRule-HLWBaaA4HA ==&gt; pacloud: DNAT rules are cleaned up ==&gt; pacloud: Start to delete ECS, if the deletion fails, please manually delete. ECS name: HKA-LX1700149 ==&gt; pacloud: The status of ECS is Stopped | Shutdown, will try to delete directly ==&gt; pacloud: ECS deleted successfully ==&gt; pacloud: Start to clean the security group ... ==&gt; pacloud: This execution creates a security group rule with ID: SecurityGroupRule-iKFRlu8B0p will try to delete, if the deletion fails, please manually delete ==&gt; pacloud: Security Group Rules Succeed Delete ==&gt; pacloud: No security group was created in this execution, no need to delete ==&gt; pacloud: The security group is cleaned up ==&gt; pacloud: Start to clean up NAT resources ... ==&gt; pacloud: Found 2 NAT IPs and started cleaning ... ==&gt; pacloud: Start to clean up the first NAT IP, IP: 118.143.215.231 ==&gt; pacloud: Deleted successfully ==&gt; pacloud: Start to clean up the second NAT IP, IP: 118.143.215.154 ==&gt; pacloud: Deleted successfully ==&gt; pacloud: After the NAT IP is cleaned up, the bandwidth packets are cleaned up. Bandwidth package: {NAT-BW-X1700034 1 1 Available | Available NatBandWidth-7NIiA3hqCp Hour | By hour packer 2019-06-17 11:34:04 HEMINGYE603 NatBrandWidthType-Hour} ==&gt; pacloud: Bandwidth package is deleted successfully ==&gt; pacloud: NAT resources are cleaned up ==&gt; pacloud: Start to clean up Network resources ... ==&gt; pacloud: No subnet was created in this execution, no need to delete ==&gt; pacloud: No network was created in this execution, no need to delete ==&gt; pacloud: No VPC was created in this execution, no need to delete ==&gt; pacloud: Network resources are cleaned up ==&gt; pacloud: The steps are all completed, try to get the image ID ==&gt; pacloud: Successfully created, image ID: Image-WB9sKza3Jj ==&gt; pacloud: End of construction, total time: 542 seconds Build 'pacloud' finished. ==&gt; Builds finished. The artifacts of successful builds are: --&gt; pacloud: Image has been created, image ID: 'Image-WB9sKza3Jj'</code></pre> <p>&nbsp;</p>
Did the above content solve your problem? Yes No
Please complete information!

Call us

400-151-8800

Email us

cloud@pingan.com

Online customer service

Instant reply

Technical Support

cloud products