Application Tasks - One-off Containers


When your app is deployed on our infrastructure, the Procfile of your project is analyzed and the different way to start your project are registered and are available for scaling in your dashboard.

For various reasons you may need to run other tasks in the environment of your application (a database migration, Rails console, rake tasks, etc.).

If you’re looking to execute scheduled tasks, you’d better read this page.


The feature requires your workstation to allow connections to the TCP port 5000. Otherwise you will experience timeouts during the connection attempts.

Run a Detached One-Off

By default one-off containers are started as attached command, it means it will only get started when a terminal interactively connect to it through the one-off endpoint. Once attached, data should be sent to the one-off or from it, otherwise the connection will be automatically closed after 30 minutes and the container will be stopped. For long interactive jobs, make sure the process is writing something to stdout or stderr.

If the --detached option is set, the container will be started as a background one-off container. In this case the container is started instantly, logs from the job are aggregated to the total logs of the application. You have to make sure this job ends at some point.


To achieve those operations you have to use the command run of our command line tool which will launch a one-off container.

Tasks can be interactive (like bash) or non-interactive (like rake task or shell command like ls -l).

A one-off container is a copy of your production environment. After the execution of the task, the environment is destroyed. Thus, do not expect any created file to show up in your production environment. The production environment is immutable.

Execute a shell command

$ scalingo --app my-app run ls
app  bin  config  db  Gemfile  Gemfile.lock  lib  log  Procfile  public  Rakefile  test  tmp  vendor

Don’t forget to quote command argument:

$ scalingo --app my-app run 'ls -l'
total 40
drwxrwxr-x 1 appsdeck appsdeck    84 Sep 23 07:42 app
drwxrwxr-x 1 appsdeck appsdeck   114 Sep 23 07:42 bin
drwxrwxr-x 1 appsdeck appsdeck   226 Sep 23 07:42 config
-rw-rw-r-- 1 appsdeck appsdeck   154 Sep 23 07:42
drwxrwxr-x 1 appsdeck appsdeck    48 Sep 23 07:42 db
-rw-rw-r-- 1 appsdeck appsdeck  2208 Sep 23 07:42 Gemfile
-rw-rw-r-- 1 appsdeck appsdeck 11085 Sep 23 07:42 Gemfile.lock
drwxrwxr-x 1 appsdeck appsdeck    40 Sep 23 07:42 lib
drwxrwxr-x 1 appsdeck appsdeck    38 Sep 23 07:42 log
-rw-rw-r-- 1 appsdeck appsdeck   137 Sep 23 07:42 Procfile
drwxrwxr-x 1 appsdeck appsdeck   220 Sep 23 07:42 public
-rw-rw-r-- 1 appsdeck appsdeck   249 Sep 23 07:42 Rakefile
drwxrwxr-x 1 appsdeck appsdeck   128 Sep 23 07:42 test
drwxrwxr-x 1 appsdeck appsdeck    76 Sep 23 07:43 tmp
drwxrwxr-x 1 appsdeck appsdeck    56 Nov 13  2014 vendor

Execute bash

$ scalingo --app my-app run bash
[10:45] Scalingo ~ $ ls
bin  Godeps  main.go  Procfile  templates

Connecting to the database

You can use the script dbclient-fetcher to download and install it. Using this script is as simple as:

[10:48] Scalingo ~ $ dbclient-fetcher mongo
---> Download and extract the database CLI
---> Database CLI installed:
MongoDB shell version: 3.4.9

If you ever need a specific version, just add it as a second parameter:

[10:48] Scalingo ~ $ dbclient-fetcher mongo 3.2
---> Download and extract the database CLI
---> Database CLI installed:
MongoDB shell version: 3.2.17

Execute bash with custom environment variables

$ scalingo --app my-app run --env VAR1=VAL1 --env VAR2=VAL2 bash
[10:51] Scalingo ~ $ env | grep VAR

Upload an archive and extract it on the server

  • Use the --file flag to select the files to upload
$ scalingo --app my-app run --file ./dump.tar bash
Upload /tmp/job-file635294589/dump.tar to container.
  • Uploaded files are located in the directory /tmp/uploads
[10:51] Scalingo ~ $ ls /tmp/uploads
  • Extract the archive to /tmp
[10:51] Scalingo ~ $ tar -C /tmp -xvf /tmp/uploads/dump.tar
  • Use these files with a script
[10:51] Scalingo ~ $ /app/ /tmp/dump/*.json

mode_edit Suggest edits