Modifying /etc/network/interfaces on alpine container template

ltilley

New Member
Jan 15, 2018
3
0
1
34
I'm trying to set up some ansible playbooks to more easily provision proxmox containers with my normal dev environment to be able to quickly test out ideas/apps, etc. For quick stuff like this (which is often temporary) I use dnsmasq to handle dhcp, and then act as a dns for dhcp clients so you can just access the new container by its hostname.

On other linux distros, the default dhcp client reports the machine's hostname to the dhcp server by default, however alpine uses busybox's udhcpc client which doesn't. This is easily fixed by adding "udhcpc_opts -h $HOSTNAME" to /etc/network/interfaces.

Here comes my issue. I want to create a custom alpine template that has enough stuff set up to be able to be able to provision with ansible (specifically, ssh and python), so I did the following steps:
  • create a new container with the default alpine template, with dhcp configured for networking
  • install openssh and configure
  • install python2
  • add "udhcpc_opts -h $HOSTNAME" to /etc/network/interfaces
  • add an empty .pve-ignore.interfaces in /etc/network
  • create a backup of the template and then move that backup into /var/lib/vz/template/cache on the proxmox host
My problem is that .pve-ignore.interfaces - though present in the .tar.gz backup - is deleted when the container is created and then /etc/network/interfaces is overwritten.

I've tried some alternative methods to get around this:
  • adding a script that re-runs udhcpc in /etc/network/if-up.d
    • while this works once the container is booted, it causes the boot process to hang
  • adding a script in local.d that re-runs udhcpc.
    • This works and doesn't hang the boot sequence, but is also deleted when the container is created.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!