I am new here and this is my first post, so first of all I want to say thank you for providing this fabulous software. I am coming from proxmox to incus, because for me, it is so much easier to create and move around instances even in multiple server setups. I loved proxmox, but now incus is my new love and I use it really heavily on my homelab mainly for educational purposes to learn more about virtualisation, networking and everything around.
So, what I noticed a few time now is a very strange thing, I have an LXC, where I setup some local connections in the managed incus network in /etc/hosts. Every time I move or copy that LXC, which happened a lot lately. My entries in /etc/hosts are gone. How can that be ? Is there a special mechanism resetting the /etc/hosts for a copied instance?
ping internalserver
ping: internalserver: Name or service not known
more /etc/hosts
127.0.1.1 test1
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
So, after the move, the entry for the name internalserver is gone … strange
The reason the /etc/hosts file is not copied (and other parameters) using incus copy with default parameters is because you run the risk of having the same mac address for two instances on a network, which creates havoc. So incus automatically prevents this by resetting some of the container fingerprint information for every copy, including /etc/hosts
If you want to preserve the /etc/hosts file, you can use the –refresh option when copying, which creates a full copy of the container (including mac address and /etc/hosts). This creates an exact copy of the container, just note that if you run this new container elsewhere on the same system or run it reliably even on another systsm in the same network. If you copy –refresh an instance to another system that is on a different network, it will run without such conflict, and it has the advantage of having the exact same fingerprints. I use this –refresh capability EXTENSIVELY in my homelab, to create fail-over capabilities for my critical services. For example, consider these:-
So I create a container, ct1, and copy it firstly locally. The container ct2 on the local system cannot be started while ct1 exists, because of a clash of mac address, but the same container (even with the same name!) on remote server ‘remote’ can be started successfully and it will have the exact same /etc/hosts, MAC id etc. as the original (it is a full, perfect copy). Note that it is still important that the container ct3 on the remote system is not on the same network as the original container else it will have unpredictable results.
copy –refresh is an elegant means of creating exact copies, and it’s super fast as it copies incrementally. As I said before, I use this EXTENSIVELY to update my large containers and vm’s.