Access LXC IP programmatically

Gautier

New Member
Nov 12, 2017
3
0
1
30
Hello!

I'm building a PaaS on top of Proxmox (very basic, just for educational purpose) and everything is working well except I can't get a container IP address from the REST API.

Basically when a user init a project locally (something like heroku create) my tool will use the Proxmox REST API to create a new LXC (with IP assigned by dhcp). But then I have to open the container web console manually from the Proxmox UI and type hostname -I to get the IP. Then I can use this IP to deploy the local app to the container.

Do you know a way to get the container IP address programmatically? Or a way to push data from a local laptop (without having access to the host) to the container?

Thanks for your help.
Gautier
 
Last edited:
Thanks for your message!
My IP is set by dhcp so I only see "ip=dhcp" in the config...
 
In this case you can acquire IP from your DHCP server. You know MAC from proxmox, and based on that you can get IP from your DHCP server.
 
or you can execute a command in the container like this:
Code:
pct exec <ID> -- ip addr
 
Hi dcsapak!

Is it possible to execute this command using the REST API? If not how can I execute it without having ssh access to the host?

Thanks
 
no this is not possible via the api at the moment
 
Hi everyone,

Getting the IP address assigned by a DHCP to an LXC container would be great feature to have in the API. I'm creating a kind of homelab scenario in my laptop using vagrant and proxmox and can live at the moment by getting the IP with a simple: "lxc-info -iH --name vm_id" . I do not even have to deal with ARPs or asking the DHCP server, but as said, it is only localhost.

Maybe getting the IP gets complicated when a container is moved within a cluster, maybe not :)
 
  • Like
Reactions: Editor
Just ran up against this issue myself. Terrible there's no easy solution from LXC.

Yeah, openVZ was far superior in accounting in many many ways -- you could get your own vmstat, your own load counter, your own IP list off each container immediately and easily - and centrally reported. Figuring out which container is out of control on CPU/load usage was easy. Now I have to hunt down where an IP has been assigned sometimes because customers ask questions based on their IPs (not container ID# or hostname). Then I have to go find it. PCT is much worse than vzctl

and I'm not even using DHCP. It'd be insanity otherwise. I'd have to go check the switch to figure out which port a mac address is on (after mapping mac to IP), to figure out which host of many the container is on, then i'd have to exec on every container to be sure DHCP ips didnt change. Wow.
 

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!