docker-xmrig

Xmrig containeried to mine monero cryptocurrency

View on GitHub

Xmrig - Monero Miner in Docker

Xmrig is an open-source project for mining Monero cryptocurrency. It allows you to mine locally for a pool and receive Monero for your efforts.

Here, you can launch Xmrig in a Podman or Docker container and to easily run it on Kubernetes, or your local computer using standard Docker commands.

Getting Started

To mine for your wallet, you need a Monero wallet (see MyMonero) and follow the instructions below to configure the container accordingly.

Launching Xmrig

docker run --rm -it ghcr.io/metal3d/xmrig:latest
# podman
podman run --rm -it ghcr.io/metal3d/xmrig:latest

By default, without any options, you will mine for me, which is a way to support the project. To mine for your wallet, modify the options using environment variables:

export POOL_URL="your pool URL"
export POOL_USER="Your public Monero address"
export POOL_PASS="can be empty for some pools, otherwise use it as miner ID"
export DONATE_LEVEL="Xmrig project donation in percent, default is 5"

# Update the image
docker pull ghcr.io/metal3d/xmrig:latest
# or with podman
podman pull ghcr.io/metal3d/xmrig:latest
# Launch the Docker container
docker run --name miner --rm -it \
    -e POOL_URL=$POOL_URL \
    -e POOL_USER=$POOL_USER \
    -e POOL_PASS=$POOL_PASS \
    -e DONATE_LEVEL=$DONATE_LEVEL \
    ghcr.io/metal3d/xmrig:latest
# or with podman
podman run --name miner --rm -it \
    -e POOL_URL=$POOL_URL \
    -e POOL_USER=$POOL_USER \
    -e POOL_PASS=$POOL_PASS \
    -e DONATE_LEVEL=$DONATE_LEVEL \
    ghcr.io/metal3d/xmrig:latest

DONATE_LEVEL is not a donation to me, it’s the donation included in the Xmrig project to support its developers. Please leave it at the default value of 5 or higher to contribute to the project.

Press CTRL+C to stop the container, and it will be automatically removed.

Environment Variables

Using CUDA

Follow instructions from Nvidia documentation and the page for Podman using CDI if you prefer Podman.

To use CUDA devices:

# Replace podman with docker if you are using Docker
podman run --rm -it \
    --device nvidia.com/gpu=all \
    --security-opt=label=disable \ # podman only
    -e CUDA=true \
    ghcr.io/metal3d/xmrig:latest

# You can compute only on GPU, but it's not recommended due to frequent GPU errors
podman run --rm -it \
    --device nvidia.com/gpu=all \
    --security-opt=label=disable \ # podman only
    -e CUDA=true \
    -e NO_CPU=true \
    ghcr.io/metal3d/xmrig:latest

Notes about MSR (Model Specific Registry)

Xmrig requires setting MSR (Model Specific Registry) to achieve optimal hashrates. If MSR is not allowed, your hashrate will be low, and a warning will appear in the terminal. To enable MSR inside the container (for Podman), use the following commands:

# Basic mining with CPU (replace podman with docker if you are using Docker)
sudo podman run --rm -it \
    --privileged \
    ghcr.io/metal3d/xmrig:latest

# To use CUDA devices
sudo podman run --rm -it \
    --privileged \
    --device nvidia.com/gpu=all \
    -e CUDA=true \
    ghcr.io/metal3d/xmrig:latest