Developer Documentation

Container Shell

Once you’re application is deployed and services are running, you can connect to a specific service instance and gain shell access into the container.

This is useful for various maintenance tasks, running arbitrary commands and debugging problems.

Connecting to Your Service Instance over SSH

From within your project’s directory:

# Launching `sh` shell into a specific service
envirobly exec <service-name>

# Arguments allow you to choose a specific instance, if service is running with multiple instances,
# as well as a different shell. Instance numbers/slots start from 0.
# To exec into the first instance with Bash shell:
envirobly exec <service-name> --instance-slot 0 --shell bash

# You can also pick a different user to connect to your container as,
# given such user exists within the container
envirobly exec <service-name> --shell bash --user root

The above examples use the default project specified in .envirobly/defaults and environ name based on current Git branch you’re in. To connect to different project and/or environ, you can use arguments like so:

# Connect to "production" environ specifically
envirobly exec <service-name> --environ-name production

# Connect to "production" environ within a project named "project-2"
envirobly exec <service-name> --environ-name production --project-name project-2

# You can specify project by ID too:
envirobly exec <service-name> --environ-name production --project-id 123

# See all the "exec" options:
envirobly help exec

One Shot Commands

You can suffix exec with a custom command, which will be executed on the target service instance as a single command and the output returned to you:

# Check memory usage on the first instance of service named "toy-store"
envirobly exec toy-store free -h

# You can use arguments to change environ, instance-slot, project-name, etc.
envirobly exec toy-store free -h --environ-name staging --instance-slot 1