-
Notifications
You must be signed in to change notification settings - Fork 341
Description
After reading the specific documentation https://pyarmor.readthedocs.io/en/stable/how-to/register.html#run-unlimited-dockers-in-offline-device, I encountered several problems trying to apply it to my environments (Windows host, WSL & docker desktop, Linux containers).
I read the previous open issues but did not find a working solution.
So, after several attempts, I found a working solution, which I describe below, hoping it will be useful.
Linked issues:
- License problem on WSL #2217
- Error using Group license inside docker despite correct registration:
this license is not for this machine#2214 - [BUG]
ERROR: this group device license is not for this machineon Windows but not on Linux #2212 - [BUG] WSL workflow #2196
- [BUG]
ERROR device (4) is not for this machine#2141
and more...
PyArmor Group on Windows + Docker Desktop (centralized proxy)
This guide explains how to reliably use a PyArmor Group license with Docker Desktop on Windows using the official "Run unlimited dockers in offline device" approach. It describes the initial scenario, the centralized proxy solution implemented in this repo, and the essential operational steps.
Initial scenario
- Windows host with Docker Desktop (Linux containers), registered as an offline PyArmor device (Windows device regfile).
- Requirement: run PyArmor inside a Docker container while reusing the host license.
- Problem: on Docker Desktop,
host.docker.internalis not in the same L3 subnet as containers; PyArmor requires an on-net (same-subnet) auth endpoint for the unlimited-dockers mode.
Adopted solution (in this project)
pyarmor-authruns on Windows using the Windows device regfile.- A centralized TCP proxy (socat-based) runs in a shared Docker network
pyarmor-net(172.30.0.0/24) with a fixed IP 172.30.0.10. - Each application stack attaches to
pyarmor-netand mapshost.docker.internal-> 172.30.0.10. This makes the auth endpoint appear on-net and license checks succeed.
Repo components:
- Substack:
pyarmor-proxy/docker-compose.yml(createspyarmor-netand starts the central proxy at 172.30.0.10) - Application stacks:
your-app-image,your-app-image2,... (attached topyarmor-netwithextra_hostspointing to the proxy)
Prerequisites
- PyArmor installed on Windows and a valid Group license (activation/registration files).
- Docker Desktop running on Windows.
- PowerShell (pwsh) recommended as your shell.
Step-by-step
- Start the PyArmor auth server on Windows (using the Windows device regfile):
pyarmor-auth C:\path\to\pyarmor-device-regfile-xxxx.N.zip
# Expected: "listen container auth request on 0.0.0.0:29092"- Start the centralized proxy (also creates the shared
pyarmor-netif missing):
pyarmor-proxy/docker-compose.yml
FROM alpine:3.19
RUN apk add --no-cache socat
EXPOSE 29092
# Forward local 29092 to Windows host via Docker Desktop mapping
ENTRYPOINT ["socat","-d","-d","TCP-LISTEN:29092,fork,reuseaddr","TCP:host.docker.internal:29092"](docker network inspect pyarmor-net >/dev/null 2>&1) || docker network create --subnet=172.30.0.0/24 pyarmor-net
docker compose -f ./pyarmor-proxy/docker-compose.yml up -d --build- Start an application stack (already configured to use the proxy):
docker compose -f ./your-app-image/docker-compose.yml up -d --build- Register PyArmor inside the container with the Windows device regfile (if not already done there):
docker cp "C:\path\to\pyarmor-device-regfile-xxxx.N.zip" your-app-image:/
docker exec -it your-app-image bashpyarmor reg /home/coder/project/pyarmor-device-regfile-xxxx.N.zip
pyarmor -v- Quick checks
ping -c 1 host.docker.internal
curl -v telnet://host.docker.internal:29092
echo "print('hello world')" > foo.py
pyarmor gen --enable-rft foo.pyHow it works (why the proxy is needed)
- On Docker Desktop, the IP behind
host.docker.internalis typically not in the same subnet as containers. PyArmor requires an on-net endpoint for unlimited-dockers. - The centralized proxy lives in the same Docker network as the app containers (
pyarmor-net) and forwards tohost.docker.internal:29092(routed to Windows by Docker Desktop). PyArmor thus sees a peer in the same network and license verification succeeds.
Minimal example (app service)
Application stacks use a shared external network and map the host to the proxy:
services:
app:
image: your-app-image
extra_hosts:
# Map host.docker.internal to the on-net PyArmor proxy (same-subnet requirement)
- "host.docker.internal:172.30.0.10"
networks:
# Attach pyarmor-net first (primary) so default route matches the host mapping
- pyarmor-net
networks:
pyarmor-net:
external: trueNotes:
- If 172.30.0.0/24 conflicts in your environment, adjust the subnet in
pyarmor-proxy/docker-compose.ymland updateextra_hostsin your stacks. - Ensure
pyarmor-authis reachable on TCP/29092 (Windows firewall rules).
Troubleshooting
-
"this license is not for this machine" during
gen:- Verify reachability to the proxy:
ping host.docker.internal,curl -v telnet://host.docker.internal:29092. - Ensure
pyarmor-authuses the Windows device regfile. - Inside the container,
pyarmor -vshould show a valid Group license for your product.
- Verify reachability to the proxy:
-
"out of license":
- PyArmor is not registered in the container or cannot reach the auth server. Register with the correct device regfile and check connectivity.
-
Versions:
- Keep PyArmor versions aligned between host and container (same major recommended). Aligning Python versions is not strictly required for this solution, but generally reduces runtime differences.