Andrey Petrov
Smack-Fu Master, in training
On the Python/Docker question: the Docker SDK (pip install docker) starts paying off once you need more than fire-and-forget. It talks to the Engine API directly, so you get container objects, exit codes, exceptions and log streams instead of parsing CLI output. On Windows it connects to Docker Desktop's named pipe by itself (it pulls in pywin32 there), which also gets you out of PowerShell quoting. The one gap is Compose. There is no official Python API for it, so if you use docker compose you'll still shell out for that part.
I wouldn't try to mount the database for the config files. Docker has no built-in way to expose database rows as files, and the FUSE projects you found only help on Linux. The SDK has a portable alternative. container.put_archive(path, data) unpacks a tar archive into a container, and container.get_archive(path) hands one back. You can build the tar in memory with tarfile and io.BytesIO straight from the blobs in SQLite, so nothing gets written to the host.
It also works on a container that has been created but not started yet. So the flow becomes create, copy the configs in, start. When a lab ends, pull the config directory with get_archive, compare each file with what's in the database (a hash per file is enough) and write back only what changed.
The Apache problem is the socket: /var/run/docker.sock is owned by root and the docker group. Adding the Apache user to that group would make it work, but it effectively gives the web server root on the box. Your current split, a privileged helper plus an unprivileged web front end, is the right shape. Python can do SysV message queues with the third-party sysv_ipc module, but that module doesn't exist on Windows. A small HTTP service bound to 127.0.0.1 is portable: run it as a user in the docker group, let it expose only the few actions the web side needs, like starting or stopping a lab, and have PHP call it with curl.
I wouldn't try to mount the database for the config files. Docker has no built-in way to expose database rows as files, and the FUSE projects you found only help on Linux. The SDK has a portable alternative. container.put_archive(path, data) unpacks a tar archive into a container, and container.get_archive(path) hands one back. You can build the tar in memory with tarfile and io.BytesIO straight from the blobs in SQLite, so nothing gets written to the host.
It also works on a container that has been created but not started yet. So the flow becomes create, copy the configs in, start. When a lab ends, pull the config directory with get_archive, compare each file with what's in the database (a hash per file is enough) and write back only what changed.
The Apache problem is the socket: /var/run/docker.sock is owned by root and the docker group. Adding the Apache user to that group would make it work, but it effectively gives the web server root on the box. Your current split, a privileged helper plus an unprivileged web front end, is the right shape. Python can do SysV message queues with the third-party sysv_ipc module, but that module doesn't exist on Windows. A small HTTP service bound to 127.0.0.1 is portable: run it as a user in the docker group, let it expose only the few actions the web side needs, like starting or stopping a lab, and have PHP call it with curl.