Create a Docker Container using Cursor¶
| Category | AI Agents & MCP |
| Status | โ Completed |
| Repo | nextwork-create-a-docker-container-using-cursor |
| Original NextWork guide | nextwork.ai |
Learning project
Practice work following a NextWork guide, separate from my production projects.
๐ NextWork learning project. This is a practice project I built while working through NextWork's Create a Docker Container using Cursor guide. It is part of my Learning portfolio and is fully separate from my production projects.
Category: Learning โบ AI Agents & MCP
Status: โ
Completed
Overview¶
The goal is to control Docker by chatting instead of typing commands. An AI client connects to the Docker MCP server, which exposes create-container, list-containers, get-logs, and deploy-compose. The model turns my sentence into a tool call. I used a local model as the client, so no account or API key is needed.
Summary¶
Natural-language prompts created and inspected a PostgreSQL container through the Docker MCP server, Adminer shows the database in a browser, and the secret mission (logs by prompt) is done. The MCP client is my own small client driven by a local model, standing in for Cursor's agent.
The checks behind this are in docs/verification.txt.
Skills & tools¶
Model Context Protocol (MCP), Docker, PostgreSQL, Adminer, Ollama tool calling, Python
What I built¶
nl_docker.py: a natural-language Docker client (Ollama tool calling โ Docker MCP server over stdio).docs/create-run.txt,docs/list-run.txt,docs/logs-run.txt: the prompt โ tool call โ result transcripts (creating my-db, listing containers, and the secret-mission logs).docker-compose.yml: PostgreSQL plus Adminer on http://localhost:8081.docs/adminer.png: Adminer logged in to thenextworkdatabase (headless-Chrome screenshot).verify_docker_mcp.py: a no-LLM check that the MCP server exposes the tools and that my-db is running.
How to run¶
ollama pull qwen2.5:1.5b
pip install mcp ollama
python nl_docker.py "Create a Postgres container named my-db from postgres:16 with POSTGRES_DB=nextwork, POSTGRES_USER=admin, POSTGRES_PASSWORD=<choose one>; ports {\"5433\": \"5432\"}"
python nl_docker.py "Show me the latest logs of my-db"
docker compose up -d # Adminer at http://localhost:8081 (server: db, user: admin)
Verification¶
I ran the verification command on 2026-12-02. The full output is in docs/verification.txt.
PATH=/workspace/nextwork-portfolio/.venv/bin:$PATH python verify_docker_mcp.py 2>/dev/null
Notes¶
Two real-world lessons:
1. Port mapping direction. On the first try the model passed {"5432/tcp": "5433"}, and this Docker MCP server read it as host 5432 โ container 5433, so Postgres was unreachable. I removed that container and re-prompted with the server's convention ({"5433": "5432"}, host โ container). It worked, and psql -h 127.0.0.1 -p 5433 connected to PostgreSQL 16.
2. Pin MCP server dependencies. The current docker-mcp package fails with the newest mcp SDK, so it runs with uv run --exclude-newer 2025-01-15 --with docker-mcp docker-mcp.
The password is the guide's throwaway practice value for a local container. Don't reuse it.
Model/provider substitution: Cursor is a desktop IDE with a sign-in, and my build machine is headless. nl_docker.py is a minimal MCP client where a local Ollama model turns the prompt into Docker MCP tool calls, which is the same loop Cursor's agent runs. Docker Desktop is replaced by Docker Engine on Linux.
Original project: https://nextwork.ai/projects/4b773c49-8a82-5db1-8464-78eaa8077b10 ยท Part of my NextWork Learning portfolio (hub).
Verification output¶
From docs/verification.txt:
$ PATH=/workspace/nextwork-portfolio/.venv/bin:$PATH python verify_docker_mcp.py 2>/dev/null
tools: ['create-container', 'deploy-compose', 'get-logs', 'list-containers']
All Docker Containers:
e7d2db7ee869 - docker-mcp-adminer-1 - running
6ceff7d7a2bf - docker-mcp-db-1 - running
6362b2898032 - my-db - running
Debug Info:
Listing all Docker containers
DOCKER MCP OK
[exit code 0]