Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running DHCP renew lease command from Docker Alpine Container

Tags:

docker

dhcp

I am trying to manage my container host interface(one of the interface) from docker container. I am able to change ip address and assign static ip to interface but it looks like when i am flushing ip address in case of dhcp, I need to renew the lease using dhclient eth1 which doesn't run inside container because there s no such package installed container. What would be best approach so I can renew lease ?

I am running container using docker run --net=host --cap-add=NET_ADMIN -v /etc/network/:/mnt/network -p 8080 -d ubuntu_network command where ubuntu_network is my custom application. Any help would be appreciated.

I couldn't find any relevant document for this.

I should be able to renew lease from container to container host interfaces.

like image 901
Arun POONIA Avatar asked Sep 16 '25 02:09

Arun POONIA


2 Answers

This is a bit late, but running udhcpc inside Alpine Linux seemed to work for me to get a new DHCP address.

like image 198
arcus Avatar answered Sep 19 '25 05:09

arcus


Within Alpine Linux, if the system is configured to obtain network configurations via DHCP, a DHCP refresh can be triggered with the following command:

/etc/init.d/networking restart

via https://wiki.alpinelinux.org/wiki/Configure_Networking#Activating_Changes_and_Testing_Connectivity

like image 33
Abdull Avatar answered Sep 19 '25 05:09

Abdull