# Docker

There's not just one correct way to use Docker; there's plenty. On this page, however, we'll describe a minimal setup ready to go using docker compose (opens new window).


If you are a visual learner, you might want to check out our screencast tutorial about "How to run Jesse using Docker (opens new window)" on YouTube.

If you're looking for a ready to work repository, see jesse-stack-docker (opens new window). You just need to copy the contents of the docker-compose.yml file into a file on your system.

This docker-compose.yml file has 3 services: the jesse framework, postgresql database, and the jesse trade info (opens new window) web chart utility which is used to explore backtest result. Two services (the jesse and db) mount your local directories to the containers so the jesse can read your strategies and the database can keep candles data and trades history permenantly.

If you're looking for a ready to work repository, see jesse-stack-docker (opens new window). Click on Use as template and pull your forked repo locally. This repository uses a docker-compose file that includes different services: main jesse, postgres database, jesse trade info (opens new window) web chart US to explore backtest result. It mounts locally files to persist on your machine the database data contains trade history use for backtest, and your Jesse strategy files:

# docker-compose.yml
version: '3.8'


    image: salehmir/jesse:latest
      - db
      - jesse-trades-info

# Inject api credentials from host env (only for live):

# Inject api credentials from env file (only for live):
#    env_file:
#      .env

      - 8888:8888
      - ./jesseData:/home
# Mount the live package as volume (only for live):
#      - ./jesse_live-0.0.2-cp39-cp39-manylinux2010_x86_64.whl:/jesse_live-0.0.2-cp39-cp39-manylinux2010_x86_64.whl

    image: jessetradesinfo/jesse-trades-info:v0.2.1
      - db
      DB_HOST: db
      DB_NAME: jesse_db
      DB_USER: jesse_user
      DB_PASSWORD: password
      DB_PORT: 5432
      - 3000:3000

    image: postgres:12-alpine
      POSTGRES_USER: jesse_user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: jesse_db
      - 5432:5432
      - ./dbData:/var/lib/postgresql/data

Start Jesse container and its dependencies:

docker-compose run jesse bash

Now you're logged into a terminal inside the Jesse container. If you remember, we had mounted the working local directory to the jesse container, so now we can open it with a code editor outside the container and start writing codes. First of all, let's create a new project at /home inside the container:

cd /home
jesse make-project mybot

Now you'll find a mybot directory in your local machine. Open it with your code editor and write your own strategies.

When you're done with the container, you can exit using exit command.

To stop all containers, run the stop command:

docker-compose stop

Next time you want to access the container, of course, you don't need to repeat the above steps. Just restart the container and then start the database:

docker-compose run jesse bash

# Managing sensitive config values

Jesse supports environment variable injection for any config file keys. The key format follows this rule: join the config node and replace the by _. Env variable must be prefixed with ENV_.

For example, databases -> postgres -> host value will be taken from env variables with the key ENV_DATABASES_POSTGRES_HOST.

To keep your config file versioned, it's recommended to inject API key and secret.

An example for binance testnet futures keys (exchanges -> Testnet Binance Futures -> api_key) would be: