Coder Social home page Coder Social logo

docker-metatrader-obsv's Introduction

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:

  • start a container:
# docker build -f Dockerfile.mt5-64bit .
  • let wine automatically install the missing packages.
  • stop the container without any further actions (by closing MetaTrader).
  • commit the changes to a new image, e.g.:
# docker commit cc349c658225 mt

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:

  • build the image as described in Building the image.
  • create a temporary directory on your host, that MetaTrader is going to be installed in.
# mkdir /tmp/mt
  • download the metatrader installer (mt4setup.exe or mt5setup.exe) from MetaQuotes and place it in /tmp/mt.
  • start the container with the install directory mounted to /home/wine and bash as entry point:
# docker run \
	-ti \
        --net host \
        -v /tmp/.X11-unix:/tmp/.X11-unix \
        -e DISPLAY \
        -v /tmp/mt:/home/wine \
        --entrypoint=/bin/sh \
        tickelton/mt
  • install MetaTrader:
# wine /home/wine/mt5setup.exe
  • MetaTrader is now installed into /tmp/mt/.wine/drive_c/Program Files/MetaTrader 5/
  • you can now save this directory and run your dockerized MetaTrader from there:
# cp -r /tmp/mt/.wine/drive_c/Program Files/MetaTrader 5/ $HOME/MetaTrader
...
# docker run \
        --net host \
        -v /tmp/.X11-unix:/tmp/.X11-unix \
        -e DISPLAY \
        -v $HOME/MetaTrader:/MetaTrader \
        --name mt \
        tickelton/mt

docker-metatrader-obsv's People

Contributors

tickelton avatar vladdsm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.