Leveraging Docker with TensorFlow Models & TensorFlow.js for a Snake AI Game
A browser-based Snake game whose AI mode uses a TensorFlow.js feedforward network (dense layers 5→256→512→256→3, Adam at 0.001, MSE loss) to choose left, forward or right from the snake's surroundings, retraining on its recorded moves after each game. The static site is served from an nginx:latest container built with a two-line Dockerfile, and a bind-mounted volume gives live reload during development without rebuilding the image. The walkthrough covers the game loop, mode switching, training and prediction code, and a fix for Docker Desktop file-sharing mount errors.
Related posts
- Build a dinosaur runner game with Deno, pt. 2
Deno mediumAdeptStage 2 of a Deno dinosaur runner tutorial turns a static landing page into a playable HTML5 canvas game. A DinoGame class tracks game state, runs a requestAnimationFrame update/render loop, handles Space, arrow-up and click input for jumping, and applies simple gravity and velocity physics with a ground clamp. The stage also covers canvas rendering of a rectangle dino, DOM score and status helpers, reset logic and a health check against the Stage 1 Oak API, all deployable to Deno Deploy.
- Making ML-powered web games with Transformers.js
Hugging Face mediumAdeptDoodle Dash is a Quick, Draw!-style sketch-guessing game that runs entirely in the browser, using a MobileViT-small model (5.6M parameters, ~20 MB) fine-tuned on Google's Quick, Draw! dataset. The model is converted to ONNX with Optimum and run via Transformers.js in a Web Worker so inference doesn't block the UI, producing over 60 predictions per second with no server latency. The game loop is redesigned around that real-time speed: players draw as many prompts as they can in 60 seconds, and scores for early incorrect labels are progressively suppressed. Ambiguous or hard-to-draw classes were pruned, leaving over 300 categories.
- Build a dinosaur runner game with Deno, pt. 3
Deno mediumAdeptPart 3 of a Deno tutorial series adds obstacles and collision detection to a canvas-based dinosaur runner game. Cactus obstacles spawn on a frame timer, move left at the game speed, and award points when they leave the screen. An axis-aligned bounding-box overlap check ends the run, and a difficulty level computed every 200 points raises speed and shortens the spawn interval down to a floor. The stage also adds a simple leg animation, a game-over overlay, high scores persisted in localStorage, and redeployment with `deno deploy`.
- How to Build, Run, and Package AI Models Locally with Docker Model Runner
Docker mediumAdeptDocker Model Runner, enabled as a beta feature in Docker Desktop 4.40+, pulls GGUF-format LLMs from Docker Hub or Hugging Face and runs them locally via the `docker model` CLI or an OpenAI-compatible HTTP endpoint on localhost. The guide walks through enabling the feature, pulling, tagging and pushing models to a local registry, one-shot and interactive prompts, curl calls to the chat completions API, and packaging your own .gguf file with a license as an OCI artifact. Constraints noted: only GGUF is supported, one model is loaded at a time, and models unload after 5 minutes idle. Compose v2.35+ can declare models as services and inject connection URLs into dependent containers.
- Docker Model Runner on the new NVIDIA DGX Spark: a new paradigm for developing AI locally
Docker mediumAdeptDocker Model Runner now supports NVIDIA DGX Spark, a compact Grace Blackwell GB10 workstation with 128GB of unified memory, for running large models locally. Setup means installing the docker-model-plugin on DGX OS's preinstalled Docker Engine and pulling a model such as ai/qwen3-coder, which is exposed through an OpenAI-compatible API on port 12434 with GPUs passed through nvidia-container-runtime. SSH port forwarding lets a laptop use the Spark as a remote model host and view its GPU dashboard, shown with a sample OpenCode configuration that points the coding agent at the local Qwen3-Coder endpoint.