How to install MetaTrader 5 on a Linux VPS (Docker, Wine, Xvfb)
Run MT5 headless on an Ubuntu VPS so AI agents can read prices and place demo orders around the clock.
What you need
An Ubuntu VPS with 2 CPUs and 4 GB of RAM or more, Docker, and a broker demo account (server name, account number and the trading password).
The approach
MT5 is a Windows program. On Linux it runs under Wine, with Xvfb as a virtual screen and a small web viewer (noVNC) so you can see the terminal from a browser when needed. Everything lives in one Docker container that restarts by itself.
Connecting your agents
Recent MT5 builds include an MCP server that tools can talk to locally. Keep it on 127.0.0.1, put a tiny gateway in front of it that only allows the actions you want (read account, open with a stop, close), and never expose it to the internet.
Common traps
Using the website password instead of the trading password; Algo Trading switched off; markets closed on weekends; symbols with a suffix (for example XAUUSDr). The course walks through each one with screenshots.