Containers are the centre piece of the Anbox Cloud stack. Every time you launch an application or an image, Anbox Cloud creates a container for it. Every container provides a full Android system.
All containers in Anbox Cloud are ephemeral, which means that as soon as a container is stopped, all of its data is deleted. Anbox Cloud DOES NOT back up any data from the Android or the outer Ubuntu container. Backup and restore of data must be implemented separately through addons. See Example: Back up data for information on how to do this.
Regular containers vs. base containers
Anbox Cloud differentiates between two types of containers: regular containers and base containers. The container type is visible in the output of the amc ls
command.
Regular containers are containers that are launched from either an application or an image. They exist until they are deleted.
Base containers are temporary containers that are used when bootstrapping an application. They are automatically deleted when the application bootstrap is completed.
When we refer to containers in this documentation without specifying the container type, we mean regular containers.
Application containers vs. raw containers
Containers are based on either applications or images. That means that if you launch an application or an image, Anbox Management Service (AMS) automatically creates a container for it.
Application containers are containers created when launching an application and run the full Android system. If the application is based on an Android app (an APK package), this app is launched after the system boots and monitored by the watchdog. With the default configuration, you will see only the app and not the Android launcher.
Raw containers are containers created when launching an image. They run the full Android system, without any additional apps installed.
Container life cycle
Creating a container
When you create a container by either launching or initialising an application or an image, AMS schedules the container on a LXD node. The container then executes the following steps in order:
- Configure the network interface and gateway.
- (Only for raw containers) Install addons that are specified with
--addons
. - Expose services that are specified with
--service
or through the application manifest. - Execute the
pre-start
hook provided by the installed addons. - Launch the Android container.
- Execute the
post-start
hook provided by the installed addons.
The container launch process is successful only if all of the above steps succeed. If there are issues during the process, the status of the container changes to the error
status. You can view the available logs from the container for further troubleshooting.
Stopping a container
Containers can be stopped because of the following scenarios:
- You stopped it.
- You deleted it.
- An error occurred.
When a container is stopped, it executes the following steps in order:
- Stop the Android container.
- Execute the
post-stop
hook provided by the installed addons. - Shut down the container.
Beyond that, the container will be removed from AMS either because you deleted it or because an error occurred during its runtime.
Possible container status
A container moves through different stages and correspondingly have the following status depending on its current state.
Status | Description |
---|---|
created |
AMS has created an internal database object for the container and will next schedule the container onto a suitable LXD node. |
prepared |
AMS has decided the LXD node on which it will schedule the container. |
started |
The container is started and now booting. During the boot sequence, possible hooks are executed. Only when all hooks have been executed, the container will switch to running . |
running |
The container is fully up and running. |
stopped |
The container is fully stopped and will be deleted by AMS. |
deleted |
The container is deleted and will be removed from the AMS database soon. |
error |
An error occurred while processing the container. The container is stopped. Further information about the error can be viewed with amc show <container id> . |
Development mode
AMS allows to start a container in development mode. This mode turns off some features that are usually active in a container. It is mainly useful when developing addons inside a container.
When development mode is enabled, the container sends status updates to AMS when the Anbox runtime is terminated, however, AMS allows the container to continue running. This allows you to restart the Anbox runtime inside the container, providing an easy way to test addons or develop a platform plugin.
To check whether development mode is enabled, run amc show <container_ID>
or look at the /var/lib/anbox/session.yaml
file in the container. If the devmode
field in the configuration file is set to true
, development mode is active.
Related information
- How to create a container
- How to start a container
- How to wait for a container
- How to access a container
- How to expose services on a container
- How to view the container logs
- How to stop a container
- How to delete a container
- How to list containers
- How to configure geographic location
- How to back up and restore application data