tickelton / docker-metatrader

MetaTrader4/5 in a container
ISC License
112 stars 53 forks source link

docker-metatrader

Since MetaTrader does not work equally well with all versions of wine and installing several versions and switching between them can be a rather unpleasant experience, running MetaTrader with wine in a Docker container is a very convenient solution.

Requirements

This repository contains two Dockerfiles. One for running 64bit MetaTrader 5 and one for running 32bit MetaTrader 4. The images built from these Dockerfiles only provide a wine installation compatible with MetaTrader 4 or MetaTrader 5 and the entry point to run MetaTrader automatically.

MetaTrader itself is not included and has to be supplied separately.

The MetaTrader directory needed by the image can be acquired either by installing MetaTrader on a Windows machine and copying the installation directory (usually C:\Program\ Files\MetaTrader[45]) or by running the installer in a container and retrieving it from there (see MetaTrader installation using a container).

Usage

Note 1: It is assumed that there is a MetaTrader installation in the host directory $HOME/MetaTrader/.

Note 2: The container runs as an unprivileged user with UID/GID 1000/1000. This UID needs to have write access to the host directory containing your MetaTrader installation. If this is not the case, you have to change the IDs in the Dockerfile before building the image.

Building the image with:

# docker build -f Dockerfile.mt5-64bit .

will result in an image containing a suitable installation of Wine but missing the gecko and mono packages.

Therefore if this image is used as is, it will work just fine but install those packages on every start of a container.

This issue can be solved as follow:

The resulting image "mt" will now start MetaTrader immediately without any further prompts.

EXAMPLES

Building the image:

# git clone https://github.com/tickelton/docker-metatrader.git
# cd docker-metatrader
# docker build .

Starting a container

# docker run \
        --net host \
        -v /tmp/.X11-unix:/tmp/.X11-unix \
        -e DISPLAY \
        -v $METATRADER_HOST_PATH:/MetaTrader \
        --name mt \
        tickelton/mt

MetaTrader installation using a container

If you do not have a working MetaTrader installation that you can make available in the container, it is possible to install MetaTrader using this very image and retrieving the installation directory from there.

The process for this is as follows: