Sign inSign up

crazykoodaa/mt5_client_vnc

By crazykoodaa

•Updated over 1 year ago

MetaTrader 5 trading platform running in Docker. Access with web browser (vnc) and Python API RPyC.

Image
Integration & delivery
Data science
Web servers
0

376

crazykoodaa/mt5_client_vnc repository overview

⁠🚀 MetaTrader 5 Docker with VNC Access

A ready-to-use MetaTrader 5 trading platform running in Docker with remote desktop access through your web browser. No Windows required!

⁠📦 What's Inside?

  • MetaTrader 5 - Latest version with auto-update capability
  • Wine 10.0 - Windows compatibility layer for Linux
  • KasmVNC - Access MT5 through your web browser
  • Python Integration - mt5linux bridge for automated trading
  • Pre-configured - Ready to connect to your broker

⁠🎯 Quick Start (For Beginners)

⁠Step 1: Get the Docker Image

Open your terminal and type:

docker pull YOUR_USERNAME/mt5_client_vnc:latest
⁠Step 2: Start MetaTrader 5

Run this command:

docker run -d \
  --name my_mt5 \
  -p 6080:6901 \
  -p 5900:5900 \
  -p 8001:8001 \
  -v mt5_data:/config \
  YOUR_USERNAME/mt5_client_vnc:latest
⁠Step 3: Open MetaTrader 5
  1. Open your web browser (Chrome, Firefox, etc.)
  2. Go to: http://localhost:6080/index.html
  3. You'll see MetaTrader 5 running! 🎉

⁠🔌 Available Ports

PortWhat it's for
6080Web Browser Access (recommended)
5900VNC Client Access (advanced users)
8001Python/API Connection

⁠🖥️ How to Connect

⁠Easy Way - Web Browser:
  1. Open http://localhost:6080/index.html
  2. No password needed by default
  3. Start trading!
⁠Advanced Way - VNC Client:
  • Server: localhost:5900
  • Password: No password (blank)
⁠Change VNC Password (Optional):
# Enter the container
docker exec -it my_mt5 bash

# Set a new password
x11vnc -storepasswd your_new_password ~/.vnc/passwd

# Restart the container
docker restart my_mt5

⁠⚙️ MetaTrader 5 Setup

⁠First Time Setup:
  1. When MT5 opens, click "File" → "Login to Trade Account"
  2. Enter your broker's server (ask your broker for this)
  3. Enter your account number and password
  4. Click "OK" to connect
⁠Enable Auto-Trading:
  1. Click "Tools" → "Options"
  2. Go to "Expert Advisors" tab
  3. Check these boxes:
    • ✅ Allow automated trading
    • ✅ Allow DLL imports
    • ✅ Allow WebRequest for listed URL
  4. Click "OK"
⁠For Python/API Trading:

Add these URLs to WebRequest whitelist:

  1. Go to "Tools" → "Options" → "Expert Advisors"
  2. Check "Allow WebRequest for listed URL"
  3. Add these URLs:
    • http://localhost:8001
    • http://127.0.0.1:8001
    • Your broker's API URL (if needed)

⁠🐍 Connect with Python

⁠Install Python Library:
pip install MetaTrader5 rpyc
⁠Simple Connection Example:
import rpyc

# Connect to MT5 in Docker
connection = rpyc.connect("localhost", 8001)
mt5 = connection.root

# Initialize MT5
if mt5.initialize():
    print("Connected to MT5!")

    # Get account info
    account_info = mt5.account_info()
    print(f"Balance: ${account_info.balance}")

    # Shutdown
    mt5.shutdown()

⁠💾 Save Your Data

Your MT5 settings and files are saved in Docker volume mt5_data. To backup:

# Create backup
docker run --rm -v mt5_data:/config -v $(pwd):/backup \
  alpine tar czf /backup/mt5_backup.tar.gz -C /config .

# Restore backup
docker run --rm -v mt5_data:/config -v $(pwd):/backup \
  alpine tar xzf /backup/mt5_backup.tar.gz -C /config

⁠🛠️ Troubleshooting

⁠Can't see MT5 window?
  • Make sure Docker is running: docker ps
  • Check if container started: docker logs my_mt5
  • Try refreshing browser: Ctrl+F5
⁠MT5 won't connect to broker?
  1. Check internet in container: docker exec my_mt5 ping google.com
  2. Verify broker server address is correct
  3. Check if your account is active with broker
⁠Python can't connect?
  • Ensure port 8001 is mapped: -p 8001:8001
  • Check if mt5linux is running: docker exec my_mt5 ps aux | grep mt5linux

⁠🎮 Useful Commands

# Stop MT5
docker stop my_mt5

# Start MT5 again
docker start my_mt5

# Remove container (data is safe in volume)
docker rm my_mt5

# See what's happening
docker logs my_mt5

# Enter container terminal
docker exec -it my_mt5 bash

⁠📝 Tips for Beginners

  1. Always test on demo account first!
  2. Save your login details - Write them down somewhere safe
  3. Don't share your VNC if you expose ports to internet
  4. Regular backups - Backup your mt5_data volume weekly
  5. One instance at a time - Don't run multiple containers with same account

⁠🔒 Make Your Connection Secure (Encryption)

⁠Why Do I Need This?

Think of encryption like putting your trading data in a locked box while sending it over the internet. Without it, anyone could peek inside!

When you need encryption:

  • ✅ Accessing MT5 from another computer
  • ✅ Trading from a coffee shop WiFi
  • ✅ Using MT5 from your phone
  • ❌ Only using on your home computer (optional)
⁠🏠 Option A: Self-Signed Certificate (For Testing)

This is like making your own lock - it works, but browsers will warn you it's "not trusted". That's OK for testing!

⁠Step 1: Create Your Certificate
# Enter the container
docker exec -it my_mt5 bash

# Make a folder for certificates
mkdir -p /config/ssl

# Create your certificate (just press ENTER for all questions)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout /config/ssl/selfsigned.key \
  -out /config/ssl/selfsigned.crt \
  -subj "/C=US/ST=State/L=City/O=MyTrading/CN=localhost"

# Exit container
exit
⁠Step 2: Start MT5 with HTTPS
# Stop old container
docker stop my_mt5
docker rm my_mt5

# Start with HTTPS enabled
docker run -d \
  --name my_mt5 \
  -p 6443:6901 \
  -p 5900:5900 \
  -p 8443:8001 \
  -v mt5_data:/config \
  -e SSL_CERT=/config/ssl/selfsigned.crt \
  -e SSL_KEY=/config/ssl/selfsigned.key \
  crazykoodaa/mt5_client_vnc:latest
⁠Step 3: Connect Securely
  1. Open: https://localhost:6443/index.html (note: https not http)
  2. Browser will say "Not Secure" - click "Advanced" → "Proceed"
  3. You're now encrypted! 🔒
⁠🌐 Option B: Let's Encrypt (For Real Trading)

This is like getting a lock from a trusted locksmith - no browser warnings!

⁠What You Need First:
  • A domain name (like mt5.yourdomain.com)
  • Domain pointing to your server's IP
⁠Step 1: Install Nginx Proxy Manager
# Create a network for our containers
docker network create mt5_network

# Start Nginx Proxy Manager
docker run -d \
  --name nginx_proxy \
  --network mt5_network \
  -p 80:80 \
  -p 443:443 \
  -p 81:81 \
  -v npm_data:/data \
  -v npm_letsencrypt:/etc/letsencrypt \
  jc21/nginx-proxy-manager:latest
⁠Step 2: Start MT5 on the Network
docker run -d \
  --name my_mt5 \
  --network mt5_network \
  -v mt5_data:/config \
  crazykoodaa/mt5_client_vnc:latest
⁠Step 3: Setup SSL Certificate
  1. Go to: http://your-server-ip:81
  2. Login:
  3. Click "Proxy Hosts" → "Add Proxy Host"
  4. Fill in:
    • Domain: mt5.yourdomain.com
    • Forward IP: my_mt5
    • Forward Port: 6901
  5. Go to "SSL" tab:
    • Choose "Request Let's Encrypt"
    • Check "Force SSL"
    • Click "Save"

Now access MT5 at: https://mt5.yourdomain.com 🎉

⁠🐍 Secure Python Connection
⁠For Self-Signed Certificate:
import rpyc
import ssl

# Trust our self-signed certificate
config = {"ssl_context": ssl._create_unverified_context()}

# Connect securely
connection = rpyc.connect("localhost", 8443, config=config)
mt5 = connection.root
⁠For Production with Nginx:
import rpyc

# Nginx handles SSL, so connect normally
connection = rpyc.connect("mt5.yourdomain.com", 8001)
mt5 = connection.root
⁠📱 Access from Phone/Tablet

With encryption set up:

  1. Self-Signed: Go to https://your-computer-ip:6443
  2. Let's Encrypt: Go to https://mt5.yourdomain.com
  3. Add to home screen for app-like experience!
⁠⚡ Quick Security Checklist
  • Using encryption (HTTPS)?
  • Changed default VNC password?
  • Only necessary ports exposed?
  • Strong MT5 account password?
  • Firewall configured?

⁠🚨 Security Notes

  • Local only? Default setup is fine
  • Internet access? MUST use encryption + password
  • Public WiFi? ALWAYS use encryption
  • Shared computer? Always logout when done
  • Never share your MT5 login credentials

⁠🤝 Need Help?

  • MT5 Help: Press F1 in MetaTrader 5
  • Docker Issues: Check Docker documentation
  • Trading Questions: Contact your broker

Remember: This is just software. Always trade responsibly and never risk money you can't afford to lose! 📊💡

Tag summary

Content type

Image

Digest

sha256:815f7bef9…

Size

1.9 GB

Last updated

over 1 year ago

docker pull crazykoodaa/mt5_client_vnc:working-backup