From e6b64c39411ea619e32b88f569b617f932349c2e Mon Sep 17 00:00:00 2001 From: Adphi Date: Wed, 21 Jan 2026 17:11:38 +0100 Subject: [PATCH 1/3] feat: add `--hostname` flag to customize the vm hostname Signed-off-by: Adphi --- README.md | 2 ++ builder.go | 10 ++++++++-- cmd/d2vm/build.go | 1 + cmd/d2vm/convert.go | 1 + cmd/d2vm/flags.go | 3 +++ convert.go | 2 +- convert_options.go | 8 ++++++++ docs/content/reference/d2vm_build.md | 1 + docs/content/reference/d2vm_convert.md | 1 + 9 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 703c284..9440da6 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ Flags: --bootloader string Bootloader to use: syslinux, grub, grub-bios, grub-efi, defaults to syslinux on amd64 and grub-efi on arm64 --force Override output qcow2 image -h, --help help for convert + --hostname string Hostname to set in the generated image (default "localhost") --keep-cache Keep the images after the build --luks-password string Password to use for the LUKS encrypted root partition. If not set, the root partition will not be encrypted --network-manager string Network manager to use for the image: none, netplan, ifupdown @@ -331,6 +332,7 @@ Flags: -f, --file string Name of the Dockerfile --force Override output qcow2 image -h, --help help for build + --hostname string Hostname to set in the generated image (default "localhost") --keep-cache Keep the images after the build --luks-password string Password to use for the LUKS encrypted root partition. If not set, the root partition will not be encrypted --network-manager string Network manager to use for the image: none, netplan, ifupdown diff --git a/builder.go b/builder.go index 04d89aa..fe15db5 100644 --- a/builder.go +++ b/builder.go @@ -83,9 +83,11 @@ type builder struct { cmdLineExtra string arch string + + hostname string } -func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, osRelease OSRelease, format string, cmdLineExtra string, splitBoot bool, bootFS BootFS, bootSize uint64, luksPassword string, bootLoader string, platform string) (Builder, error) { +func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, osRelease OSRelease, format string, cmdLineExtra string, splitBoot bool, bootFS BootFS, bootSize uint64, luksPassword string, bootLoader string, platform, hostname string) (Builder, error) { var arch string switch platform { case "linux/amd64": @@ -179,6 +181,9 @@ func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, // logrus.Warnf("%s is smaller than rootfs size, using %s", datasize.ByteSize(size), s) // size = int64(s) // } + if hostname == "" { + hostname = "localhost" + } b := &builder{ osRelease: osRelease, config: config, @@ -195,6 +200,7 @@ func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, bootFS: bootFS, luksPassword: luksPassword, arch: arch, + hostname: hostname, } if err := b.checkDependencies(); err != nil { return nil, err @@ -412,7 +418,7 @@ func (b *builder) setupRootFS(ctx context.Context) (err error) { if err := b.chWriteFileIfNotExist("/etc/resolv.conf", "nameserver 8.8.8.8", 0644); err != nil { return err } - if err := b.chWriteFileIfNotExist("/etc/hostname", "localhost", perm); err != nil { + if err := b.chWriteFile("/etc/hostname", b.hostname+"\n", perm); err != nil { return err } if err := b.chWriteFileIfNotExist("/etc/hosts", hosts, perm); err != nil { diff --git a/cmd/d2vm/build.go b/cmd/d2vm/build.go index 3d9f97e..59e797f 100644 --- a/cmd/d2vm/build.go +++ b/cmd/d2vm/build.go @@ -110,6 +110,7 @@ var ( d2vm.WithKeepCache(keepCache), d2vm.WithPlatform(platform), d2vm.WithPull(false), + d2vm.WithHostname(hostname), ); err != nil { return err } diff --git a/cmd/d2vm/convert.go b/cmd/d2vm/convert.go index 6aea732..b986ee5 100644 --- a/cmd/d2vm/convert.go +++ b/cmd/d2vm/convert.go @@ -91,6 +91,7 @@ var ( d2vm.WithKeepCache(keepCache), d2vm.WithPlatform(platform), d2vm.WithPull(pull), + d2vm.WithHostname(hostname), ); err != nil { return err } diff --git a/cmd/d2vm/flags.go b/cmd/d2vm/flags.go index b97abbd..737b185 100644 --- a/cmd/d2vm/flags.go +++ b/cmd/d2vm/flags.go @@ -44,6 +44,8 @@ var ( keepCache bool platform string + + hostname string ) func validateFlags() error { @@ -116,5 +118,6 @@ func buildFlags() *pflag.FlagSet { flags.BoolVar(&keepCache, "keep-cache", false, "Keep the images after the build") flags.StringVar(&platform, "platform", d2vm.Arch, "Platform to use for the container disk image, linux/arm64 and linux/arm64 are supported") flags.BoolVar(&pull, "pull", false, "Always pull docker image") + flags.StringVar(&hostname, "hostname", "localhost", "Hostname to set in the generated image") return flags } diff --git a/convert.go b/convert.go index 769de35..945c7fd 100644 --- a/convert.go +++ b/convert.go @@ -88,7 +88,7 @@ func Convert(ctx context.Context, img string, opts ...ConvertOption) error { if format == "" { format = "raw" } - b, err := NewBuilder(ctx, tmpPath, imgUUID, "", o.size, r, format, o.cmdLineExtra, o.splitBoot, o.bootFS, o.bootSize, o.luksPassword, o.bootLoader, o.platform) + b, err := NewBuilder(ctx, tmpPath, imgUUID, "", o.size, r, format, o.cmdLineExtra, o.splitBoot, o.bootFS, o.bootSize, o.luksPassword, o.bootLoader, o.platform, o.hostname) if err != nil { return err } diff --git a/convert_options.go b/convert_options.go index 47efd13..f003687 100644 --- a/convert_options.go +++ b/convert_options.go @@ -34,6 +34,8 @@ type convertOptions struct { keepCache bool platform string pull bool + + hostname string } func (o *convertOptions) hasGrubBIOS() bool { @@ -127,3 +129,9 @@ func WithPull(b bool) ConvertOption { o.pull = b } } + +func WithHostname(hostname string) ConvertOption { + return func(o *convertOptions) { + o.hostname = hostname + } +} diff --git a/docs/content/reference/d2vm_build.md b/docs/content/reference/d2vm_build.md index 110eab7..4114f70 100644 --- a/docs/content/reference/d2vm_build.md +++ b/docs/content/reference/d2vm_build.md @@ -17,6 +17,7 @@ d2vm build [context directory] [flags] -f, --file string Name of the Dockerfile --force Override output qcow2 image -h, --help help for build + --hostname string Hostname to set in the generated image (default "localhost") --keep-cache Keep the images after the build --luks-password string Password to use for the LUKS encrypted root partition. If not set, the root partition will not be encrypted --network-manager string Network manager to use for the image: none, netplan, ifupdown diff --git a/docs/content/reference/d2vm_convert.md b/docs/content/reference/d2vm_convert.md index e143acb..086c209 100644 --- a/docs/content/reference/d2vm_convert.md +++ b/docs/content/reference/d2vm_convert.md @@ -15,6 +15,7 @@ d2vm convert [docker image] [flags] --bootloader string Bootloader to use: syslinux, grub, grub-bios, grub-efi, defaults to syslinux on amd64 and grub-efi on arm64 --force Override output qcow2 image -h, --help help for convert + --hostname string Hostname to set in the generated image (default "localhost") --keep-cache Keep the images after the build --luks-password string Password to use for the LUKS encrypted root partition. If not set, the root partition will not be encrypted --network-manager string Network manager to use for the image: none, netplan, ifupdown From 327937308671a41ee7769406880f9b1be7e2758b Mon Sep 17 00:00:00 2001 From: Adphi Date: Wed, 21 Jan 2026 17:23:57 +0100 Subject: [PATCH 2/3] feat: add `--dns` and `--dns-search` flags to customize the vm dns configuration Signed-off-by: Adphi --- README.md | 4 ++++ builder.go | 28 +++++++++++++++++++++++--- cmd/d2vm/build.go | 2 ++ cmd/d2vm/convert.go | 2 ++ cmd/d2vm/flags.go | 6 +++++- convert.go | 2 +- convert_options.go | 16 ++++++++++++++- docs/content/reference/d2vm_build.md | 2 ++ docs/content/reference/d2vm_convert.md | 2 ++ 9 files changed, 58 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9440da6..85cf9d8 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,8 @@ Flags: --boot-fs string Filesystem to use for the boot partition, ext4 or fat32 --boot-size uint Size of the boot partition in MB (default 100) --bootloader string Bootloader to use: syslinux, grub, grub-bios, grub-efi, defaults to syslinux on amd64 and grub-efi on arm64 + --dns strings DNS servers to set in the generated image + --dns-search strings DNS search domains to set in the generated image --force Override output qcow2 image -h, --help help for convert --hostname string Hostname to set in the generated image (default "localhost") @@ -328,6 +330,8 @@ Flags: --boot-fs string Filesystem to use for the boot partition, ext4 or fat32 --boot-size uint Size of the boot partition in MB (default 100) --bootloader string Bootloader to use: syslinux, grub, grub-bios, grub-efi, defaults to syslinux on amd64 and grub-efi on arm64 + --dns strings DNS servers to set in the generated image + --dns-search strings DNS search domains to set in the generated image --build-arg stringArray Set build-time variables -f, --file string Name of the Dockerfile --force Override output qcow2 image diff --git a/builder.go b/builder.go index fe15db5..df1a64b 100644 --- a/builder.go +++ b/builder.go @@ -84,10 +84,12 @@ type builder struct { cmdLineExtra string arch string - hostname string + hostname string + dns []string + dnsSearch []string } -func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, osRelease OSRelease, format string, cmdLineExtra string, splitBoot bool, bootFS BootFS, bootSize uint64, luksPassword string, bootLoader string, platform, hostname string) (Builder, error) { +func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, osRelease OSRelease, format string, cmdLineExtra string, splitBoot bool, bootFS BootFS, bootSize uint64, luksPassword string, bootLoader string, platform, hostname string, dns, dnsSearch []string) (Builder, error) { var arch string switch platform { case "linux/amd64": @@ -184,6 +186,9 @@ func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, if hostname == "" { hostname = "localhost" } + if len(dns) == 0 { + dns = []string{"8.8.8.8"} + } b := &builder{ osRelease: osRelease, config: config, @@ -201,6 +206,8 @@ func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, luksPassword: luksPassword, arch: arch, hostname: hostname, + dns: dns, + dnsSearch: dnsSearch, } if err := b.checkDependencies(); err != nil { return nil, err @@ -415,7 +422,7 @@ func (b *builder) setupRootFS(ctx context.Context) (err error) { if err := b.chWriteFile("/etc/fstab", fstab, perm); err != nil { return err } - if err := b.chWriteFileIfNotExist("/etc/resolv.conf", "nameserver 8.8.8.8", 0644); err != nil { + if err := b.chWriteFile("/etc/resolv.conf", b.resolvConf(), 0644); err != nil { return err } if err := b.chWriteFile("/etc/hostname", b.hostname+"\n", perm); err != nil { @@ -500,6 +507,21 @@ func (b *builder) isLuksEnabled() bool { return b.luksPassword != "" } +func (b *builder) resolvConf() string { + var sb strings.Builder + for _, v := range b.dns { + sb.WriteString("nameserver ") + sb.WriteString(v) + sb.WriteString("\n") + } + if len(b.dnsSearch) > 0 { + sb.WriteString("search ") + sb.WriteString(strings.Join(b.dnsSearch, " ")) + sb.WriteString("\n") + } + return sb.String() +} + func (b *builder) Close() error { return b.img.Close() } diff --git a/cmd/d2vm/build.go b/cmd/d2vm/build.go index 59e797f..af9f6d2 100644 --- a/cmd/d2vm/build.go +++ b/cmd/d2vm/build.go @@ -111,6 +111,8 @@ var ( d2vm.WithPlatform(platform), d2vm.WithPull(false), d2vm.WithHostname(hostname), + d2vm.WithDNS(dns), + d2vm.WithDNSSearch(dnsSearch), ); err != nil { return err } diff --git a/cmd/d2vm/convert.go b/cmd/d2vm/convert.go index b986ee5..dd8b543 100644 --- a/cmd/d2vm/convert.go +++ b/cmd/d2vm/convert.go @@ -92,6 +92,8 @@ var ( d2vm.WithPlatform(platform), d2vm.WithPull(pull), d2vm.WithHostname(hostname), + d2vm.WithDNS(dns), + d2vm.WithDNSSearch(dnsSearch), ); err != nil { return err } diff --git a/cmd/d2vm/flags.go b/cmd/d2vm/flags.go index 737b185..ea7edb6 100644 --- a/cmd/d2vm/flags.go +++ b/cmd/d2vm/flags.go @@ -45,7 +45,9 @@ var ( keepCache bool platform string - hostname string + hostname string + dns []string + dnsSearch []string ) func validateFlags() error { @@ -119,5 +121,7 @@ func buildFlags() *pflag.FlagSet { flags.StringVar(&platform, "platform", d2vm.Arch, "Platform to use for the container disk image, linux/arm64 and linux/arm64 are supported") flags.BoolVar(&pull, "pull", false, "Always pull docker image") flags.StringVar(&hostname, "hostname", "localhost", "Hostname to set in the generated image") + flags.StringSliceVar(&dns, "dns", []string{}, "DNS servers to set in the generated image") + flags.StringSliceVar(&dnsSearch, "dns-search", []string{}, "DNS search domains to set in the generated image") return flags } diff --git a/convert.go b/convert.go index 945c7fd..0d03551 100644 --- a/convert.go +++ b/convert.go @@ -88,7 +88,7 @@ func Convert(ctx context.Context, img string, opts ...ConvertOption) error { if format == "" { format = "raw" } - b, err := NewBuilder(ctx, tmpPath, imgUUID, "", o.size, r, format, o.cmdLineExtra, o.splitBoot, o.bootFS, o.bootSize, o.luksPassword, o.bootLoader, o.platform, o.hostname) + b, err := NewBuilder(ctx, tmpPath, imgUUID, "", o.size, r, format, o.cmdLineExtra, o.splitBoot, o.bootFS, o.bootSize, o.luksPassword, o.bootLoader, o.platform, o.hostname, o.dns, o.dnsSearch) if err != nil { return err } diff --git a/convert_options.go b/convert_options.go index f003687..afdc9ba 100644 --- a/convert_options.go +++ b/convert_options.go @@ -35,7 +35,9 @@ type convertOptions struct { platform string pull bool - hostname string + hostname string + dns []string + dnsSearch []string } func (o *convertOptions) hasGrubBIOS() bool { @@ -135,3 +137,15 @@ func WithHostname(hostname string) ConvertOption { o.hostname = hostname } } + +func WithDNS(dns []string) ConvertOption { + return func(o *convertOptions) { + o.dns = dns + } +} + +func WithDNSSearch(dnsSearch []string) ConvertOption { + return func(o *convertOptions) { + o.dnsSearch = dnsSearch + } +} diff --git a/docs/content/reference/d2vm_build.md b/docs/content/reference/d2vm_build.md index 4114f70..007214d 100644 --- a/docs/content/reference/d2vm_build.md +++ b/docs/content/reference/d2vm_build.md @@ -14,6 +14,8 @@ d2vm build [context directory] [flags] --boot-size uint Size of the boot partition in MB (default 100) --bootloader string Bootloader to use: syslinux, grub, grub-bios, grub-efi, defaults to syslinux on amd64 and grub-efi on arm64 --build-arg stringArray Set build-time variables + --dns strings DNS servers to set in the generated image + --dns-search strings DNS search domains to set in the generated image -f, --file string Name of the Dockerfile --force Override output qcow2 image -h, --help help for build diff --git a/docs/content/reference/d2vm_convert.md b/docs/content/reference/d2vm_convert.md index 086c209..fcd260e 100644 --- a/docs/content/reference/d2vm_convert.md +++ b/docs/content/reference/d2vm_convert.md @@ -13,6 +13,8 @@ d2vm convert [docker image] [flags] --boot-fs string Filesystem to use for the boot partition, ext4 or fat32 --boot-size uint Size of the boot partition in MB (default 100) --bootloader string Bootloader to use: syslinux, grub, grub-bios, grub-efi, defaults to syslinux on amd64 and grub-efi on arm64 + --dns strings DNS servers to set in the generated image + --dns-search strings DNS search domains to set in the generated image --force Override output qcow2 image -h, --help help for convert --hostname string Hostname to set in the generated image (default "localhost") From 2d8d06a9cc71a6f5e5e339f979ce9b870e47e3f6 Mon Sep 17 00:00:00 2001 From: Adphi Date: Wed, 21 Jan 2026 17:42:48 +0100 Subject: [PATCH 3/3] feat: add `--add-host` flag to customize host-to-IP mapping in /etc/hosts Signed-off-by: Adphi --- README.md | 2 ++ builder.go | 10 ++++++++-- cmd/d2vm/build.go | 1 + cmd/d2vm/convert.go | 1 + cmd/d2vm/flags.go | 23 ++++++++++++++++++++++- convert.go | 2 +- convert_options.go | 7 +++++++ docs/content/reference/d2vm_build.md | 1 + docs/content/reference/d2vm_convert.md | 1 + 9 files changed, 44 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 85cf9d8..cfdc66f 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ Usage: Flags: --append-to-cmdline string Extra kernel cmdline arguments to append to the generated one + --add-host strings Add a custom host-to-IP mapping (host:ip) to the /etc/hosts file in the generated image --boot-fs string Filesystem to use for the boot partition, ext4 or fat32 --boot-size uint Size of the boot partition in MB (default 100) --bootloader string Bootloader to use: syslinux, grub, grub-bios, grub-efi, defaults to syslinux on amd64 and grub-efi on arm64 @@ -327,6 +328,7 @@ Usage: Flags: --append-to-cmdline string Extra kernel cmdline arguments to append to the generated one + --add-host strings Add a custom host-to-IP mapping (host:ip) to the /etc/hosts file in the generated image --boot-fs string Filesystem to use for the boot partition, ext4 or fat32 --boot-size uint Size of the boot partition in MB (default 100) --bootloader string Bootloader to use: syslinux, grub, grub-bios, grub-efi, defaults to syslinux on amd64 and grub-efi on arm64 diff --git a/builder.go b/builder.go index df1a64b..3ada1dc 100644 --- a/builder.go +++ b/builder.go @@ -87,9 +87,10 @@ type builder struct { hostname string dns []string dnsSearch []string + hosts string } -func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, osRelease OSRelease, format string, cmdLineExtra string, splitBoot bool, bootFS BootFS, bootSize uint64, luksPassword string, bootLoader string, platform, hostname string, dns, dnsSearch []string) (Builder, error) { +func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, osRelease OSRelease, format string, cmdLineExtra string, splitBoot bool, bootFS BootFS, bootSize uint64, luksPassword string, bootLoader string, platform, hostname string, dns, dnsSearch []string, extraHosts map[string]string) (Builder, error) { var arch string switch platform { case "linux/amd64": @@ -189,6 +190,10 @@ func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, if len(dns) == 0 { dns = []string{"8.8.8.8"} } + hosts := hosts + for k, v := range extraHosts { + hosts += fmt.Sprintf("%s %s\n", v, k) + } b := &builder{ osRelease: osRelease, config: config, @@ -208,6 +213,7 @@ func NewBuilder(ctx context.Context, workdir, imgTag, disk string, size uint64, hostname: hostname, dns: dns, dnsSearch: dnsSearch, + hosts: hosts, } if err := b.checkDependencies(); err != nil { return nil, err @@ -428,7 +434,7 @@ func (b *builder) setupRootFS(ctx context.Context) (err error) { if err := b.chWriteFile("/etc/hostname", b.hostname+"\n", perm); err != nil { return err } - if err := b.chWriteFileIfNotExist("/etc/hosts", hosts, perm); err != nil { + if err := b.chWriteFile("/etc/hosts", b.hosts, perm); err != nil { return err } // TODO(adphi): is it the righ fix ? diff --git a/cmd/d2vm/build.go b/cmd/d2vm/build.go index af9f6d2..9ac9443 100644 --- a/cmd/d2vm/build.go +++ b/cmd/d2vm/build.go @@ -113,6 +113,7 @@ var ( d2vm.WithHostname(hostname), d2vm.WithDNS(dns), d2vm.WithDNSSearch(dnsSearch), + d2vm.WithExtraHosts(extraHosts), ); err != nil { return err } diff --git a/cmd/d2vm/convert.go b/cmd/d2vm/convert.go index dd8b543..6027302 100644 --- a/cmd/d2vm/convert.go +++ b/cmd/d2vm/convert.go @@ -94,6 +94,7 @@ var ( d2vm.WithHostname(hostname), d2vm.WithDNS(dns), d2vm.WithDNSSearch(dnsSearch), + d2vm.WithExtraHosts(extraHosts), ); err != nil { return err } diff --git a/cmd/d2vm/flags.go b/cmd/d2vm/flags.go index ea7edb6..db60a13 100644 --- a/cmd/d2vm/flags.go +++ b/cmd/d2vm/flags.go @@ -48,9 +48,12 @@ var ( hostname string dns []string dnsSearch []string + hosts []string + + extraHosts map[string]string ) -func validateFlags() error { +func validateFlags() (err error) { switch platform { case "linux/amd64": if bootloader == "" { @@ -98,6 +101,10 @@ func validateFlags() error { return fmt.Errorf("%s already exists", output) } } + extraHosts, err = validateHosts(hosts...) + if err != nil { + return fmt.Errorf("invalid --add-host value: %w", err) + } return nil } @@ -123,5 +130,19 @@ func buildFlags() *pflag.FlagSet { flags.StringVar(&hostname, "hostname", "localhost", "Hostname to set in the generated image") flags.StringSliceVar(&dns, "dns", []string{}, "DNS servers to set in the generated image") flags.StringSliceVar(&dnsSearch, "dns-search", []string{}, "DNS search domains to set in the generated image") + flags.StringSliceVar(&hosts, "add-host", []string{}, "Add a custom host-to-IP mapping (host:ip) to the /etc/hosts file in the generated image") return flags } + +func validateHosts(vals ...string) (map[string]string, error) { + out := make(map[string]string) + for _, val := range vals { + // allow for IPv6 addresses in extra hosts by only splitting on first ":" + k, v, ok := strings.Cut(val, ":") + if !ok || k == "" { + return nil, fmt.Errorf("bad format for add-host: %q", val) + } + out[k] = v + } + return out, nil +} diff --git a/convert.go b/convert.go index 0d03551..7c4a19a 100644 --- a/convert.go +++ b/convert.go @@ -88,7 +88,7 @@ func Convert(ctx context.Context, img string, opts ...ConvertOption) error { if format == "" { format = "raw" } - b, err := NewBuilder(ctx, tmpPath, imgUUID, "", o.size, r, format, o.cmdLineExtra, o.splitBoot, o.bootFS, o.bootSize, o.luksPassword, o.bootLoader, o.platform, o.hostname, o.dns, o.dnsSearch) + b, err := NewBuilder(ctx, tmpPath, imgUUID, "", o.size, r, format, o.cmdLineExtra, o.splitBoot, o.bootFS, o.bootSize, o.luksPassword, o.bootLoader, o.platform, o.hostname, o.dns, o.dnsSearch, o.hosts) if err != nil { return err } diff --git a/convert_options.go b/convert_options.go index afdc9ba..5c04fa9 100644 --- a/convert_options.go +++ b/convert_options.go @@ -38,6 +38,7 @@ type convertOptions struct { hostname string dns []string dnsSearch []string + hosts map[string]string } func (o *convertOptions) hasGrubBIOS() bool { @@ -149,3 +150,9 @@ func WithDNSSearch(dnsSearch []string) ConvertOption { o.dnsSearch = dnsSearch } } + +func WithExtraHosts(hosts map[string]string) ConvertOption { + return func(o *convertOptions) { + o.hosts = hosts + } +} diff --git a/docs/content/reference/d2vm_build.md b/docs/content/reference/d2vm_build.md index 007214d..bc3f1be 100644 --- a/docs/content/reference/d2vm_build.md +++ b/docs/content/reference/d2vm_build.md @@ -9,6 +9,7 @@ d2vm build [context directory] [flags] ### Options ``` + --add-host strings Add a custom host-to-IP mapping (host:ip) to the /etc/hosts file in the generated image --append-to-cmdline string Extra kernel cmdline arguments to append to the generated one --boot-fs string Filesystem to use for the boot partition, ext4 or fat32 --boot-size uint Size of the boot partition in MB (default 100) diff --git a/docs/content/reference/d2vm_convert.md b/docs/content/reference/d2vm_convert.md index fcd260e..cd97d29 100644 --- a/docs/content/reference/d2vm_convert.md +++ b/docs/content/reference/d2vm_convert.md @@ -9,6 +9,7 @@ d2vm convert [docker image] [flags] ### Options ``` + --add-host strings Add a custom host-to-IP mapping (host:ip) to the /etc/hosts file in the generated image --append-to-cmdline string Extra kernel cmdline arguments to append to the generated one --boot-fs string Filesystem to use for the boot partition, ext4 or fat32 --boot-size uint Size of the boot partition in MB (default 100)