Anyway to add some info to container tag after it is initialized?

Hi,

While I make some simple service with anbox cloud, I meet some suffering condition.

As I want to prepare specific number of containers in stopped status, I use AMS api of post container with no_start parameter true. (Which I think is “amc init”)

But the problem is that I want to append some data when start these containers with PATCH container “running”.

This data is strongly bond to each container, so I think container tag (which is userdata) is proper position for this. So, anyway to do this after container is initialized? or any other solution?

Thanks for your support.

P.S. +1 more question. why is it “stopped” status when no_start post container or amc init? isn’t it “prepared” ? I am quite curious of the lifecycle when only doing “amc init”.

Hey @ruin09 ,

sorry for the late reply.

As I want to prepare specific number of containers in stopped status, I use AMS api of post container with no_start parameter true. (Which I think is “amc init”)

Correct, amc init is doing exactly that.

This data is strongly bond to each container, so I think container tag (which is userdata) is proper position for this. So, anyway to do this after container is initialized? or any other solution?

That is tricky. userdata can currently only associated with an instance at creation time, so either with amc init or amc launch (or the corresponding API methods). Updating userdata after the instance has been created is not supported today.

While we can think about allowing updates to userdata, the best way to support you at the moment would be to manually update the userdata in /var/lib/anbox/userdata instance an instance by talking to LXD directly. E.g. you can push a file to a currently stopped instance via lxc file push /path/to/my-userdata ams-<instance id>/var/lib/anbox/userdata and then start the instance via amc start <instance id>. Alternatively what a lot people use is that the instance calls a remote service on startup and receives any necessary information before Anbox and Android are started. Have a look at https://anbox-cloud.io/docs/reference/hooks to see which lifecycle hooks are available. The pre-start one would fit best in this case.

P.S. +1 more question. why is it “stopped” status when no_start post container or amc init? isn’t it “prepared” ? I am quite curious of the lifecycle when only doing “amc init”.

To be honest I need to check why it is done this way. I am sure there have been reasons, but can’t remember right now.

Let us know if there is anything else we can help with!

1 Like