Common commands for administering the PyPNM Docker deployment on a host/VM.
- Working Directory
- Stack Lifecycle
- Developer Workflow
- Images And Updates
- Config Menu
- Logs And Health
- Inspect And Debug
- Cleanup
- Networking Notes
All commands below assume:
cd /opt/pypnm/composeTip: verify what services exist in your compose bundle:
sudo docker compose config --servicesStart the stack:
sudo docker compose up -dStop the stack:
sudo docker compose downStop the stack and remove named volumes (deletes stored logs/output/data in volumes):
sudo docker compose down --volumesRestart only the API service:
sudo docker compose restart pypnm-apiRecreate containers (useful after changing the image tag or ports):
sudo docker compose up -d --force-recreateLocal development relies on the same compose services, just executed from your cloned repository:
-
Clone the repo and run the installer:
git clone https://github.com/PyPNMApps/PyPNM.git cd PyPNM ./install.sh -
Build/test locally via
docker-compose.ymlhelpers:make docker-up # docker compose up -d --build make docker-logs # follow API logs make docker-down # stop + remove volumes
-
Use the Python tooling (
pytest,ruff, etc.) inside.env/for day-to-day development.
Pull the image tag referenced by your .env (or docker-compose.yml):
sudo docker compose pullShow current images in use:
sudo docker compose imagesShow container status (compose services only):
sudo docker compose psIf your compose file includes a config-menu service, run it interactively:
sudo docker compose run --rm -it config-menuIf config-menu is not listed in docker compose config --services, it is not available in the deployed bundle.
Reload the API without a container restart (only if your API exposes this endpoint):
curl -X GET "http://127.0.0.1:${HOST_PORT:-8080}/pypnm/system/webService/reload" -H "accept: application/json"Tail API logs:
sudo docker compose logs -f --tail=200 pypnm-apiFollow all logs for the API service (no tail limit):
sudo docker compose logs -f pypnm-apiQuick docs endpoint health check:
curl -I "http://127.0.0.1:${HOST_PORT:-8080}/docs"Wait for container health to turn healthy:
watch -n 1 "sudo docker ps --format 'table {{.Names}} {{.Status}} {{.Ports}}' | sed -n '1p;/pypnm-api/p'"Open a shell in the running API container:
sudo docker exec -it pypnm-api shList containers (running only):
sudo docker psList containers (all, including stopped):
sudo docker ps -aList container names only (useful for scripting):
sudo docker ps -a --format "{{.Names}}"Show effective compose configuration (after env var expansion):
sudo docker compose configInspect the container (networking, mounts, env):
sudo docker inspect pypnm-apiTest network reachability from inside the container (HTTP example):
sudo docker exec -it pypnm-api sh -lc "python -c 'import urllib.request; urllib.request.urlopen("http://127.0.0.1:8000/docs").read(); print("OK")'"If ping is available in the image, you can also do:
sudo docker exec -it pypnm-api ping -c 1 <target-ip>Remove a specific container:
sudo docker rm -f <container>Remove all stopped containers only:
sudo docker container prune -fRemove all containers (running and stopped). This is destructive:
sudo docker rm -f $(sudo docker ps -aq)Examples: targeted cleanup without touching other projects:
List containers and find old PyPNM instances:
sudo docker ps -a --format "table {{.Names}} {{.Image}} {{.Status}}" | grep -i pypnmRemove only containers whose names start with pypnm:
sudo docker rm -f $(sudo docker ps -a --format "{{.Names}}" | grep '^pypnm')Remove only containers created from a specific image tag:
sudo docker rm -f $(sudo docker ps -a --filter "ancestor=ghcr.io/PyPNMApps/pypnm:v0.9.48.0" -q)Remove unused images (dangling):
sudo docker image prune -fRemove unused images (all unreferenced by any container):
sudo docker image prune -a -fPrune unused resources (stopped containers, dangling images, unused networks):
sudo docker system prune -fAggressive prune (also removes unused images and volumes):
sudo docker system prune -a --volumes -fList Docker volumes:
sudo docker volume lsRemove a specific volume:
sudo docker volume rm <volume>Remove all unused volumes:
sudo docker volume prune -fIf the API must share host routes directly (for example, to reach modems on local LAN subnets with strict ACLs), configure host networking for the API service and recreate the stack.
- Edit
/opt/pypnm/compose/docker-compose.ymland set underpypnm-api:
network_mode: host- Recreate:
cd /opt/pypnm/compose
sudo docker compose down
sudo docker compose up -dWhen network_mode: host is enabled, published ports: mappings are ignored because the container shares the host network.