Skip to main content

Set up your Divio application locally

In this section we will build the new application you've created in the local development environment; that is, we will set it up on your own computer.

Obtain the application's slug (its unique ID) from the Dashboard:

Application slug

Alternatively you can use the divio command to list your cloud applications, which will show their slugs:

divio app list

Build the application locally

Run the divio app setup command (for example if your application slug is tutorial-project):

divio app setup tutorial-project

The Divio CLI will execute a number of steps - this may take a few minutes, depending on how much needs to be downloaded and processed. The Divio CLI tool will build your application locally (see The deployment process for a more detailed description of what's happening here). Note that depending on the application, you won't necessarily see all the intermediate steps here:

Creating workspace

cloning application repository
downloading remote docker images
building local docker images
creating new database container
syncing and migrating database
Your workspace is setup and ready to start.

As well as cloning the repository and attempting to build the application, the setup command will add a .divio directory containing some Divio-related configuration that connects it to the Control Panel.

cd into the newly-created application directory, where you will find your application code.

Start the local application

Start the application by running docker-compose up in the terminal:

➜  docker-compose up
Starting tutorial-project_db_1
Performing system checks...

System check identified no issues (0 silenced).
May 19, 2020 - 03:29:06
Django version 2.2.12, using settings 'settings'
Starting development server at
Quit the server with CONTROL-C.

Open the application in your web browser by visiting

(You may notice above that Django claims to be running on port 80, not port 8000. It is - but that's only inside the container. The docker-compose.yml configuration file is responsible for this port-mapping.)


If you didn't previously log in to the cloud site before setting up the application locally, you'll need to add a user to the database before you can log in. The Divio SSO system allows you to do this from the Django login page with the Add user option.

Or, you could run:

docker-compose run web createsuperuser

See below for more on the use of docker-compose.

CONTROL-C will stop the application.

Local commands

So far, we have used the divio, docker-compose and docker commands. It's good to have a basic familiarity with them and what they do. As you proceed through this tutorial, you may encounter the occasional issue. These commands will help you when this happens.

Other useful commands

See our local commands cheat sheet for many more useful commands.

Using divio

The divio command is used mainly to manage your local application's resources and to interact with our Control Panel. You have already used divio app setup and divio app list; you can also use it to do things like push and pull database and media content. Try:

divio app dashboard

See the Divio CLI reference for more.

Using docker

The docker command is mostly used to manage Docker processes, images and containers (rather than applications as a whole) and Docker itself. You will rarely need to use it, but it can be useful when you need to understand what Docker is doing on your machine, or for certain operations.

For example, if you have your application running locally (with docker-compose up) open a new terminal window to run:

docker ps

This will show you the Docker processes that are running - you will see something like this (note that the details will differ depending on what you actually have running):

➜ docker ps
d6007edbaf32 tutorialproject_web "/tini -g -- python..." 17 minutes ago Up 8 seconds>80/tcp tutorialproject_web_
27ff3e661027 postgres:13.5 "docker-entrypoint..." 17 minutes ago Up 8 seconds 5432/tcp tutorialproject_db_

In this example, the first container is an instance of the image that you built (when deployed, a similar container will be running in a cloud environment). The second shown here is a Postgres database, running in its own Docker container.

You have already used docker ps. Try:

docker info

Using docker-compose

The docker-compose command is used mainly to control and interact with your local application. You will mostly use it to start the local application and open a shell in the local web container. You have already used docker-compose build and docker-compose up.

Just for example, try:

docker-compose run web python shell

which will open a Django shell in the web container.

You have now set up an application in the local environment, and launched it. The next step is to do some further development work in the application, test it, and deploy it to the cloud.