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.

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, AMS automatically creates a container for it.

Application containers, thus containers created when launching an application, 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.

Containers that are created when launching an image are called raw containers. They run the full Android system, without any additional apps installed.

Data stored in containers

All containers in Anbox Cloud are ephemeral, which means that as soon as a container is stopped, all of its data is gone. 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.

Container life cycle

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:

  1. Configure the network interface and gateway.
  2. Only raw containers: Install addons that are specified with --addons.
  3. Expose services that are specified with --service or through the application manifest.
  4. Execute the pre-start hook provided by the installed addons.
  5. Launch the Android container.
  6. Execute the post-start hook provided by the installed addons.

Container start

The whole launch process is successful only if all of the above steps succeed.

If anything goes wrong during the container launch process, the status of the container changes to the error status. You can view the available logs from the container for diagnosing the root cause of the problem.

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:

  1. Stop the Android container.
  2. Execute the post-stop hook provided by the installed addons.
  3. 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.
Container stop

Possible container status

Throughout its lifetime, a container moves through different stages depending on the state it’s currently in.

Status Description
created AMS has created an internal database object for the container and will schedule the container onto a suitable LXD node next.
prepared AMS has decided on which LXD node the container will be placed.
started The container was started and is 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 does not send status updates to AMS when the Anbox runtime is terminated. This allows you to restart the Anbox runtime inside the container, providing an easy way to test addons or other extensions.

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.

Managing containers

1 Like