Container Command
Containers run the command specified by the Service they belong to:- If the service is an Implicit Service, then that command is the Image’s
CMD
. - If the service is an Explicit Service, then that command is defined by the Procfile.
Container Environment
Containers run with three types of environment variables and if there is a name collision, Aptible Metadata takes precedence over App Configuration, which takes precedence over Docker Image Variables:Docker Image Variables
Docker Images define these variables via theENV
directive. They are present when your Containers start:
App Configuration
Aptible injects an App’s Configuration as environment variables. For example, for the keysFOO
and BAR
:
FOO
and BAR
set respectively to SOME
and OTHER
.
Aptible Metadata
Finally, Aptible injects a set of metadata keys as environment variables. These environment variables are accessible through the facilities exposed by the language, such asENV
in Ruby, process.env
in Node, or os.environ
in Python.
Container Hostname
Aptible (and Docker in general) sets the hostname for your Containers to the 12 first characters of the Container’s ID and uses it in Logging and Metrics.Container Isolation
Containers on Aptible are isolated. Use one of the following options to allow multiple Containers to communicate:- For web APIs or microservices, set up an Endpoint and direct your requests to the Endpoint.
- For background workers, use a Database as a message queue. Aptible supports Redis and RabbitMQ, which are well-suited for this use case.
Container Lifecycle
Containers on Aptible are frequently recycled during Operations - meaning new Containers are created during an Operation, and the old ones are terminated. This happens within the following Operations:- Redeploying an App
- Restarting an App or Database
- Scaling an App or Database
Graceful termination
Containers are given a grace period after the initialSIGTERM
to exit before receiving a hard SIGKILL
. By default this is 10 seconds, but it can be configured via the stop timeout setting on the service. See the Releases page for more information and caveats.