Managing environment variables


This guide assumes you already know the basics of adding and editing environment variables in Maestro. If you need help with this, please follow our tutorial on the subject.

Default environment variables

Cloud 66 creates a number of default environment variables, which can be used in addition to those that you define. Depending on your application configuration, the environment variables available will differ.

For example, if you have a MySQL server, the following variables are created and inserted into your database.yml (unless you have specified your own):

For a list of environment variables available in your application:

  1. Open the Application Overview from your Dashboard
  2. Click on Environment Variables in the Application panel on the right of the screen
  3. The initial page displays all the Editable variables. You can see all the Read Only variables by clicking on that tab.

Assigning environment variables during deployment

If your application relies on specific environment variables to complete the deployment process, you will need to add them before deploying.

To do this:

  1. After you have taken a snapshot of your code (i.e. the first build) click on Environment Variables in the panel on the right.
  2. Set your variables by either manually entering them, or uploading a file that contains the variables. This file should use the following format:

Once your variables are set, Save changes and continue to deployment.

Assigning environment variables after application build

  1. Open the Application Overview from your Dashboard
  2. Click on Environment Variables in the Application panel on the right of the screen
  3. Add or update the variables as required
  4. Save and redeploy

Be aware of the following while assigning environment variables:

Managing environment variables using Toolbelt

You can also manage your environment variables using your Cloud 66 Toolbelt. There are four methods for managing env vars via Toolbelt:

Please click on the links above for detailed instructions on each of these methods.


AUTO_GENERATE allows you to insert placeholder environment variables into your application, and Cloud 66 will automatically replace them with a random string. This is useful to have Cloud 66 automatically generate values for secrets that you do not want to have committed into your repository.

To use AUTO_GENERATE, you define any (editable) environment variable with the value AUTO_GENERATE or AUTO_GENERATE_{number} where the number is the length of the value to auto-generate - ie. AUTO_GENERATE_32.

When you deploy your application, Cloud 66 will replace these placeholders with a random string of the specified length (10 is the default length).

Using this, you can safely commit your env file to your git repository without exposing the actual values of your environment variables.

Define referenced environment variable

You can define a new environment variable and reference it to an existing environment variable.

You can reference another environment variable using the following syntax:




The second method is useful when you want to specify a default value. If cloud66 can’t find the referenced environment variable it will use default value instead. (DEFAULT_VALUE is optional).


This example sets a health check variable to use the external web address variable of the application:


This example sets the key to use the external web address of the application, and sets a default IP if that variable is not available:


Intra-app referencing syntax

To reference an environment variable from another application you will need:

You can find an application’s APP_UID by clicking on Settings & Information in the Application panel on the right of the screen and then clicking on the Information tab at the top of the main panel.

The syntax for referencing variables from another app is:





This syntax still uses the term "stack" which in the process of being deprecated in Maestro. "Stack" means, for all intents and purposes, the same thing as "application".

Intra-service referencing

To refer to an environment variable on other services you can use




Calling environment variables in code

Using environment variables in your application logic is done differently depending on your application settings. Here are some common examples:

Bash scripts


YAML files

username: <%= ENV['DB_USER'] %>

.RB files

working_directory "#{ENV['STACK_PATH']}"

Using environment variables in a Dockerfile

You can pass environment variables into a Dockerfile during your build process with the $VARIABLE syntax, which will be populated with environment variable(s) set on the application. For example, to call a env named MY_VARIABLE you would use ENV MY_VARIABLE "$MY_VARIABLE"

The same example, in context:

FROM ruby:latest
RUN mkdir /myapp
WORKDIR /myapp
COPY . /myapp
CMD ["/myapp/main.rb"]

Pre-defined environment variables

There are some variables that are predefined by Cloud 66:

SERVER_NAME: Is on each server and is only available inside the server

DOCKER_HOST_IP: Is injected to each container and is only available inside containers

Note that predefined environment variables are preferable! for instance, you can define MEMCACHED_ADDRESS to be _env(DOCKER_HOST_IP) to refer to the DOCKER_HOST_IP which is one of the predefined ones.