Can I run XMRig inside a Docker container?
Yes, you can run XMRig inside a Docker container to mine Monero (XMR). Docker makes it easier to package and manage the miner, but it does not make mining faster or give you free computing power. Your results depend on your CPU, memory settings, and whether Docker runs directly on Linux or through a virtual machine.
What Docker changes—and what it does not
XMRig is a mining program that mainly uses your CPU, your computer’s general-purpose processor, to mine Monero. Docker runs programs in containers: separate environments that share the underlying operating system.
This is different from browser mining. XMRig runs as a native program inside the container, not inside a browser tab.
On a Linux host—the computer running Docker—container overhead is usually small. On Windows or macOS, Docker Desktop normally uses a Linux virtual machine, which adds another layer between XMRig and your hardware. That can make memory tuning and access to processor features harder.
Only mine on hardware you own or have explicit permission to use. A cloud server subscription does not automatically include permission to mine.
A simple container setup
Use an image you build yourself from trusted XMRig source or official release files. An image is the packaged program Docker uses to start a container. Be cautious with third-party mining images: they can contain malware or quietly redirect work to someone else’s wallet.
Prepare an XMRig config.json file containing your:
- Mining pool address. A pool combines miners’ work and shares rewards.
- Public Monero wallet address for payouts.
- CPU thread settings and any required pool credentials.
Never put your wallet’s private keys or recovery phrase in the container. Mining does not require them.
For a locally built image named xmrig-local, with XMRig configured as its startup command, a basic Linux example is:
docker run -d \
--name xmrig \
--restart unless-stopped \
--cpus="4" \
--memory="4g" \
-v "$PWD/config.json:/xmrig/config.json:ro" \
xmrig-local \
--config=/xmrig/config.json
The image name and file path depend on how you build your image. Here, :ro makes the configuration file read-only. The CPU limit caps available CPU time; it does not set XMRig’s mining thread count. Configure that separately.
The performance settings that matter
Monero uses RandomX, a mining algorithm designed to favor CPUs. Its fast mode needs a 2,080 MB dataset, plus additional working memory. A container therefore needs comfortably more than 2 GB of available memory.
For efficient mining, also consider:
- CPU cache: RandomX needs about 2 MB of L3 cache, a small, fast memory area, per mining thread.
- Huge pages: These are larger memory blocks that can improve performance. They usually require configuration on the Linux host and suitable container limits or permissions.
- CPU placement: Keeping mining threads on selected cores can improve consistency on some systems.
Do not use Docker’s broad --privileged option as a shortcut. Some XMRig processor optimizations require elevated hardware access, but those should be evaluated separately, not granted automatically.
The bottom line
Docker is a practical way to manage XMRig, especially on Linux. Check startup messages with docker logs xmrig to confirm mining works and see whether huge pages are active. Monitor temperatures and wall-power use, then compare your measured mining speed with a live profitability calculator before running continuously.
