Hi, I am new to Packer. Today I upload some files while making image using packer. When I open the file in the instance based on the new image, I find that the file is abnormal. Did I miss something?
build.pkr.hcl
required_plugins{
alicloud = {
version = ">= 1.0.7"
source = "github.com/hashicorp/alicloud"
}
}
}
source "alicloud-ecs" "root"{
region = "cn-hangzhou"
image_name = "sgx-env-installed-diff"
source_image = "centos_7_9_x64_20G_alibase_20230109.vhd"
ssh_username = "root"
instance_type = "ecs.c7.large"
associate_public_ip_address = true
io_optimized = true
internet_charge_type = "PayByTraffic"
system_disk_mapping {
disk_category = "cloud_essd"
}
run_tags = {
"Built by" = "Packer"
"Managed by" = "Packer"
}
image_force_delete = true
force_stop_instance = true
}
build{
sources = ["sources.alicloud-ecs.root"]
provisioner "file" {
source = "./system-start-loading.sh"
destination = "/opt/"
}
provisioner "file" {
source = "./package.tar.gz"
destination = "/opt/"
}
provisioner "shell" {
inline = [
"ls -al /opt",
"cat /opt/system-start-loading.sh"
]
}
}
But when I created an instance based on this image and opened the file, I got the following results:
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
~