linka-cloud / d2vm

Build Virtual Machine Image from Dockerfile or Docker image
Apache License 2.0
208 stars 31 forks source link

No ip allocated to interface of converted qcow2 image #4

Closed sanketIntel closed 1 year ago

sanketIntel commented 1 year ago

WheN I get converted qcow2 image, it is having an interface eth0 but no ip address is not allocated to it when we bring up the vm and interface is also in down state by default. Is it an expected behavior?

Adphi commented 1 year ago

Yes, this is the expected behavior. You need to create an image with a network management configuration. In the complete example netplan is used because it is the standard for ubuntu (since 18.04). It is not implemented because there are many ways to manage the network configuration: netplan / ifupdown / systemd-networkd... each distribution having its own method. Maybe it will be implemented in the future.

Adphi commented 1 year ago

I just added networking support on the branch run-push. It adds a --network-manager flag to the build and convert commands.

The supported values are:

sanketIntel commented 1 year ago

@Adphi thank you for your quick support. Now it is getting ip address. The only thing I see missing now is nameservers to resolve proxy if system is behind proxy in resolve.conf and hostname. Is is feasible to add support for it?

Adphi commented 1 year ago

@sanketIntel you're welcome.

There should be a resolv.conf with nameserver 8.8.8.8.

If you are getting the ip address from dhcp you should also configure the dhcp server to send the the nameservers.

https://github.com/linka-cloud/d2vm/blob/6b62dbfb9a56f8bbad56dd15830d58e5a5c5dc94/builder.go#L306-L311

I will make the hostname and nameservers configurable through flags in the next few days:

-h, --hostname string                Container host name
    --dns list                       Set custom DNS servers
    --dns-option list                Set DNS options
    --dns-search list                Set custom DNS search domains
    --domainname string              Container NIS domain name

If you plan to use it on real cloud environments, you may consider creating a Dockerfile using your image as the base and installing cloud-init in the image.

sanketIntel commented 1 year ago

Actually when I boot my vm using tedezed/ubuntu-container-disk:20.0 image it takes nameserver and hostname properly but when I boot VM using d2vm converted image it is not getting nameservers and hostname properly.

sanketIntel commented 1 year ago

Hi @Adphi, can you please share when this run-push branch will be merged to main?

Adphi commented 1 year ago

Hi @sanketIntel ! I still need to update the documentation and fix some things first, but it should be merged during September.

sanketIntel commented 1 year ago

Hi @Adphi, changes in run-push branch are very important for me (especially interface getting ip from dhcp-server and is in UP state). It will be really helpful if they are merged to main by this month.

Adphi commented 1 year ago

@sanketIntel the branch has been merged and v0.1.0 has been pre-released.