This project provides a Docker-based setup to run MetaTrader 5 (MT5) using Wine on a Debian-based environment. It leverages Traefik as a reverse proxy for managing HTTP/HTTPS traffic and ensures secure access through Let's Encrypt certificates. The setup includes VNC for remote desktop access and is configured to run as a background service with proper logging and environment management.
- Dockerized Environment: Simplifies deployment and management of MT5.
- Wine Compatibility: Runs MetaTrader 5 on a Linux-based system.
- Traefik Integration: Handles reverse proxying with automatic SSL certificate generation via Let's Encrypt.
- VNC Access: Provides remote desktop access to the MT5 application.
- Logging: Implements structured logging for easy monitoring and debugging.
- Environment Configuration: Easily manage settings using environment variables.
- Docker: Ensure Docker is installed on your system. Install Docker
- Docker Compose: Required for orchestrating the services. Install Docker Compose
- Domain Name: A registered domain for accessing Traefik and VNC services.
- SSL Certificate: Managed automatically via Let's Encrypt.
-
Clone the Repository
git clone -b chapter-1 --single-branch https://github.com/sesto-dev/metatrader5-linux-django-docker.git cd metatrader5-linux-django-docker
-
Configure Environment Variables
Create a
.env
file based on the provided example:cp .env.example .env
Open the
.env
file and set the necessary variables:# Backend - MT5 CUSTOM_USER=admin PASSWORD=yourpassword VNC_DOMAIN=your-vnc-domain.com # Traefik TRAEFIK_DOMAIN=your-traefik-domain.com TRAEFIK_USERNAME=yourusername ACME_EMAIL=[email protected]
Note: To generate and set the hashed password in one command for Traefik's HTTP Basic Auth, you can use the following command:
export HASHED_PASSWORD=$(openssl passwd -apr1 $PASSWORD)
-
Create Docker Network
docker network create traefik-public
-
Build and Start the Services
docker-compose up -d
This command builds the Docker images and starts the services in detached mode.
CUSTOM_USER
: Username for accessing the MT5 service.PASSWORD
: Password for the custom user.VNC_DOMAIN
: Domain for accessing the VNC service.TRAEFIK_DOMAIN
: Domain for Traefik dashboard.TRAEFIK_USERNAME
: Username for Traefik basic authentication.ACME_EMAIL
: Email address for Let's Encrypt notifications.
- Traefik: Acts as a reverse proxy with HTTPS support.
- MT5: Runs MetaTrader 5 using Wine.
/var/run/docker.sock
: Allows Traefik to monitor Docker services../config
: Stores Wine configurations and MT5 data.traefik-public-certificates
: Persists SSL certificates generated by Let's Encrypt.
-
Accessing MetaTrader 5
Navigate to
https://your-vnc-domain.com
in your web browser to access the VNC interface for MetaTrader 5. -
Traefik Dashboard
Access the Traefik dashboard at
https://your-traefik-domain.com
. You will be prompted for the Traefik username and password configured in the.env
file. -
Managing Services
-
Start Services:
docker-compose up -d
-
Stop Services:
docker-compose down
-
View Logs:
docker-compose logs -f
-
The setup uses JSON-file logging with the following configuration:
- Log Driver:
json-file
- Max Size:
1m
- Max File:
1
Logs are managed per service and can be viewed using Docker commands or integrated with external logging solutions like Promtail.
-
Traefik Not Accessible:
- Ensure that ports
80
and443
are open and not blocked by a firewall. - Verify that your domain DNS settings are correctly pointing to your server.
- Ensure that ports
-
MT5 Not Starting:
- Check the logs of the
mt5
service for any installation errors. - Ensure that Wine dependencies are properly installed.
- Check the logs of the
-
VNC Connection Issues:
- Confirm that the VNC service is running and accessible via the specified domain.
- Verify network configurations and firewall settings.
Contributions are welcome! Please follow these steps:
-
Fork the Repository
-
Create a Feature Branch
git checkout -b feature/YourFeature
-
Commit Your Changes
git commit -m "Add Your Feature"
-
Push to the Branch
git push origin feature/YourFeature
-
Open a Pull Request
This project is licensed under the MIT License.