<metaname="description"content="Freqtrade is a free and open source crypto trading bot written in Python, designed to support all major exchanges and be controlled via Telegram or builtin Web UI">
<inputclass="md-option"data-md-color-media=""data-md-color-scheme="default"data-md-color-primary="blue-grey"data-md-color-accent="tear"aria-label="Switch to dark mode"type="radio"name="__palette"id="__palette_0">
<labelclass="md-header__button md-icon"title="Switch to dark mode"for="__palette_1"hidden>
<inputclass="md-option"data-md-color-media=""data-md-color-scheme="slate"data-md-color-primary="blue-grey"data-md-color-accent="tear"aria-label="Switch to light mode"type="radio"name="__palette"id="__palette_1">
<labelclass="md-header__button md-icon"title="Switch to light mode"for="__palette_0"hidden>
<h1id="using-freqtrade-with-docker">Using Freqtrade with Docker<aclass="headerlink"href="#using-freqtrade-with-docker"title="Permanent link">¶</a></h1>
<p>This page explains how to run the bot with Docker. It is not meant to work out of the box. You'll still need to read through the documentation and understand how to properly configure it.</p>
<p>Freqtrade documentation assumes the use of Docker desktop (or the docker compose plugin).<br/>
While the docker-compose standalone installation still works, it will require changing all <code>docker compose</code> commands from <code>docker compose</code> to <code>docker-compose</code> to work (e.g. <code>docker compose up -d</code> will become <code>docker-compose up -d</code>).</p>
</div>
<detailsclass="warning">
<summary>Docker on windows</summary>
<p>If you just installed docker on a windows system, make sure to reboot your system, otherwise you might encounter unexplainable Problems related to network connectivity to docker containers.</p>
</details>
<h2id="freqtrade-with-docker">Freqtrade with docker<aclass="headerlink"href="#freqtrade-with-docker"title="Permanent link">¶</a></h2>
<p>Freqtrade provides an official Docker image on <ahref="https://hub.docker.com/r/freqtradeorg/freqtrade/">Dockerhub</a>, as well as a <ahref="https://github.com/freqtrade/freqtrade/blob/stable/docker-compose.yml">docker compose file</a> ready for usage.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<ul>
<li>The following section assumes that <code>docker</code> is installed and available to the logged in user.</li>
<li>All below commands use relative directories and will have to be executed from the directory containing the <code>docker-compose.yml</code> file.</li>
<p>Create a new directory and place the <ahref="https://raw.githubusercontent.com/freqtrade/freqtrade/stable/docker-compose.yml">docker-compose file</a> in this directory.</p>
<p>The above snippet creates a new directory called <code>ft_userdata</code>, downloads the latest compose file and pulls the freqtrade image.
The last 2 steps in the snippet create the directory with <code>user_data</code>, as well as (interactively) the default configuration based on your selections.</p>
<divclass="admonition question">
<pclass="admonition-title">How to edit the bot configuration?</p>
<p>You can edit the configuration at any time, which is available as <code>user_data/config.json</code> (within the directory <code>ft_userdata</code>) when using the above configuration.</p>
<p>You can also change the both Strategy and commands by editing the command section of your <code>docker-compose.yml</code> file.</p>
</div>
<h4id="adding-a-custom-strategy">Adding a custom strategy<aclass="headerlink"href="#adding-a-custom-strategy"title="Permanent link">¶</a></h4>
<ol>
<li>The configuration is now available as <code>user_data/config.json</code></li>
<li>Copy a custom strategy to the directory <code>user_data/strategies/</code></li>
<li>Add the Strategy' class name to the <code>docker-compose.yml</code> file</li>
</ol>
<p>The <code>SampleStrategy</code> is run by default.</p>
<divclass="admonition danger">
<pclass="admonition-title"><code>SampleStrategy</code> is just a demo!</p>
<p>The <code>SampleStrategy</code> is there for your reference and give you ideas for your own strategy.
Please always backtest your strategy and use dry-run for some time before risking real money!
You will find more information about Strategy development in the <ahref="../strategy-customization/">Strategy documentation</a>.</p>
</div>
<p>Once this is done, you're ready to launch the bot in trading mode (Dry-run or Live-trading, depending on your answer to the corresponding question you made above).</p>
<p>While the configuration generated will be mostly functional, you will still need to verify that all options correspond to what you want (like Pricing, pairlist, ...) before starting the bot.</p>
</div>
<h4id="accessing-the-ui">Accessing the UI<aclass="headerlink"href="#accessing-the-ui"title="Permanent link">¶</a></h4>
<p>If you've selected to enable FreqUI in the <code>new-config</code> step, you will have freqUI available at port <code>localhost:8080</code>.</p>
<p>You can now access the UI by typing localhost:8080 in your browser.</p>
<detailsclass="note">
<summary>UI Access on a remote server</summary>
<p>If you're running on a VPS, you should consider using either a ssh tunnel, or setup a VPN (openVPN, wireguard) to connect to your bot.
This will ensure that freqUI is not directly exposed to the internet, which is not recommended for security reasons (freqUI does not support https out of the box).
Setup of these tools is not part of this tutorial, however many good tutorials can be found on the internet.
Please also read the <ahref="../rest-api/#configuration-with-docker">API configuration with docker</a> section to learn more about this configuration.</p>
</details>
<h4id="monitoring-the-bot">Monitoring the bot<aclass="headerlink"href="#monitoring-the-bot"title="Permanent link">¶</a></h4>
<p>You can check for running instances with <code>docker compose ps</code>.
This should list the service <code>freqtrade</code> as <code>running</code>. If that's not the case, best check the logs (see next point).</p>
<p>The database will be located at: <code>user_data/tradesv3.sqlite</code></p>
<h4id="updating-freqtrade-with-docker">Updating freqtrade with docker<aclass="headerlink"href="#updating-freqtrade-with-docker"title="Permanent link">¶</a></h4>
<p>Updating freqtrade when using <code>docker</code> is as simple as running the following 2 commands:</p>
<divclass="highlight"><pre><span></span><code><spanclass="c1"># Download the latest image</span>
<p>This will first pull the latest image, and will then restart the container with the just pulled version.</p>
<divclass="admonition warning">
<pclass="admonition-title">Check the Changelog</p>
<p>You should always check the changelog for breaking changes / manual interventions required and make sure the bot starts correctly after the update.</p>
</div>
<h3id="editing-the-docker-compose-file">Editing the docker-compose file<aclass="headerlink"href="#editing-the-docker-compose-file"title="Permanent link">¶</a></h3>
<p>Advanced users may edit the docker-compose file further to include all possible options or arguments.</p>
<p>All freqtrade arguments will be available by running <code>docker compose run --rm freqtrade <command><optional arguments></code>.</p>
<divclass="admonition warning">
<pclass="admonition-title"><code>docker compose</code> for trade commands</p>
<p>Trade commands (<code>freqtrade trade <...></code>) should not be ran via <code>docker compose run</code> - but should use <code>docker compose up -d</code> instead.
This makes sure that the container is properly started (including port forwardings) and will make sure that the container will restart after a system reboot.
If you intend to use freqUI, please also ensure to adjust the <ahref="../rest-api/#configuration-with-docker">configuration accordingly</a>, otherwise the UI will not be available.</p>
</div>
<divclass="admonition note">
<pclass="admonition-title"><code>docker compose run --rm</code></p>
<p>Including <code>--rm</code> will remove the container after completion, and is highly recommended for all modes except trading mode (running with <code>freqtrade trade</code> command).</p>
</div>
<detailsclass="note">
<summary>Using docker without docker compose</summary>
<p>"<code>docker compose run --rm</code>" will require a compose file to be provided.
Some freqtrade commands that don't require authentication such as <code>list-pairs</code> can be run with "<code>docker run --rm</code>" instead.<br/>
For example <code>docker run --rm freqtradeorg/freqtrade:stable list-pairs --exchange binance --quote BTC --print-json</code>.<br/>
This can be useful for fetching exchange information to add to your <code>config.json</code> without affecting your running containers.</p>
</details>
<h4id="example-download-data-with-docker">Example: Download data with docker<aclass="headerlink"href="#example-download-data-with-docker"title="Permanent link">¶</a></h4>
<p>Download backtesting data for 5 days for the pair ETH/BTC and 1h timeframe from Binance. The data will be stored in the directory <code>user_data/data/</code> on the host.</p>
<p>Head over to the <ahref="../data-download/">Data Downloading Documentation</a> for more details on downloading data.</p>
<h4id="example-backtest-with-docker">Example: Backtest with docker<aclass="headerlink"href="#example-backtest-with-docker"title="Permanent link">¶</a></h4>
<p>Run backtesting in docker-containers for SampleStrategy and specified timerange of historical data, on 5m timeframe:</p>
<p>Head over to the <ahref="../backtesting/">Backtesting Documentation</a> to learn more.</p>
<h3id="additional-dependencies-with-docker">Additional dependencies with docker<aclass="headerlink"href="#additional-dependencies-with-docker"title="Permanent link">¶</a></h3>
<p>If your strategy requires dependencies not included in the default image - it will be necessary to build the image on your host.
For this, please create a Dockerfile containing installation steps for the additional dependencies (have a look at <ahref="https://github.com/freqtrade/freqtrade/blob/develop/docker/Dockerfile.custom">docker/Dockerfile.custom</a> for an example).</p>
<p>You'll then also need to modify the <code>docker-compose.yml</code> file and uncomment the build step, as well as rename the image to avoid naming collisions.</p>
<p>You can then run <code>docker compose build --pull</code> to build the docker image, and run it using the commands described above.</p>
<h3id="plotting-with-docker">Plotting with docker<aclass="headerlink"href="#plotting-with-docker"title="Permanent link">¶</a></h3>
<p>Commands <code>freqtrade plot-profit</code> and <code>freqtrade plot-dataframe</code> (<ahref="../plotting/">Documentation</a>) are available by changing the image to <code>*_plot</code> in your <code>docker-compose.yml</code> file.
<p>This will create a docker-container running jupyter lab, which will be accessible using <code>https://127.0.0.1:8888/lab</code>.
Please use the link that's printed in the console after startup for simplified login.</p>
<p>Since part of this image is built on your machine, it is recommended to rebuild the image from time to time to keep freqtrade (and dependencies) up-to-date.</p>
If you're on windows and just installed Docker (desktop), make sure to reboot your System. Docker can have problems with network connectivity without a restart.
You should obviously also make sure to have your <ahref="#accessing-the-ui">settings</a> accordingly.</li>
</ul>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>Due to the above, we do not recommend the usage of docker on windows for production setups, but only for experimentation, datadownload and backtesting.
Best use a linux-VPS for running freqtrade reliably.</p>
<scriptid="__config"type="application/json">{"base":"..","features":["content.code.annotate","search.share","content.code.copy","navigation.top","navigation.footer"],"search":"../assets/javascripts/workers/search.b8dbb3d2.min.js","translations":{"clipboard.copied":"Copied to clipboard","clipboard.copy":"Copy to clipboard","search.result.more.one":"1 more on this page","search.result.more.other":"# more on this page","search.result.none":"No matching documents","search.result.one":"1 matching document","search.result.other":"# matching documents","search.result.placeholder":"Type to start searching","search.result.term.missing":"Missing","select.version":"Select version"},"version":{"provider":"mike"}}</script>