content/guides/genai-claude-code-mcp/claude-code-mcp-guide.md
This guide introduces how to use Claude Code together with Docker MCP Toolkit so Claude can search Docker Hub in real time and generate a complete docker-compose.yaml from natural language.
Instead of manually writing YAML or looking for image tags, you describe your stack once — Claude uses the Model Context Protocol (MCP) to query Docker Hub and build a production-ready Compose file.
In this guide, you’ll learn how to:
docker compose updocker-compose.yamldocker compose up → Node.js + PostgreSQL live on localhost:3000Estimated time: ~15 minutes
The goal is simple: use Claude Code together with the Docker MCP Toolkit to search Docker Hub images and generate a complete Docker Compose file for a Node.js and PostgreSQL setup.
The Model Context Protocol (MCP) bridges Claude Code and Docker Desktop, giving Claude real-time access to Docker's tools. Instead of context-switching between Docker, terminal commands, and YAML editors, you describe your requirements once and Claude handles the infrastructure details.
Why this matters: This pattern scales to complex multi-service setups, database migrations, networking, security policies — all through conversational prompts.
Make sure you have:
Docker Desktop installed
Enable Docker Desktop updated with MCP Toolkit support
Claude Code installed
Public images work without credentials. For private repositories, you can add your Docker Hub username and token later.
You can connect from Docker Desktop or using the CLI.
$ claude mcp add MCP_DOCKER -s user -- docker mcp gateway run
$ cd /path/to/project
$ claude
/mcp
You should now see:
MCP_DOCKER)If not, restart Claude Code or check Docker Desktop to confirm the connection.
Claude Code generates more accurate Compose files when it can inspect a real project. Set up the application code now so the agent can bind mount it later.
Inside project folder, create a folder named app:
$ mkdir app
$ cd app
$ npm init -y
$ npm install express
Create index.js:
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("Node.js, Docker, and MCP Toolkit are working together!");
});
app.listen(3000, () => {
console.log("Server running on port 3000");
});
Add a start script to package.json:
"scripts": {
"start": "node index.js"
}
Return to your project root (cd ..) once the app is ready.
Paste this message into Claude Code:
Using the Docker Hub MCP server:
Search Docker Hub for an official Node.js image and a PostgreSQL image.
Choose stable, commonly used tags such as the Node LTS version and a recent major Postgres version.
Generate a Docker Compose file (`docker-compose.yaml`) with:
- app:
- runs on port 3000
- bind mounts the existing ./app directory into /usr/src/app
- sets /usr/src/app as the working directory and runs `npm install && npm start`
- db: running on port 5432 using a named volume
Include:
- Environment variables for Postgres
- A shared bridge network
- Healthchecks where appropriate
- Pin the image version using the tag + index digest
Claude will search images through MCP, inspect the app directory, and generate a Compose file that mounts and runs your local code.
Tell Claude:
Save the final Docker Compose file (docker-compose.yaml) into the current project directory.
You should see something like this:
services:
app:
image: node:<tag>
working_dir: /usr/src/app
volumes:
- .:/usr/src/app
ports:
- "3000:3000"
depends_on:
- db
networks:
- app-net
db:
image: postgres:18
environment:
POSTGRES_USER: example
POSTGRES_PASSWORD: example
POSTGRES_DB: appdb
volumes:
- db-data:/var/lib/postgresql
ports:
- "5432:5432"
networks:
- app-net
volumes:
db-data:
networks:
app-net:
driver: bridge
From your project root:
$ docker compose up
Docker will:
Open your browser:
http://localhost:3000
Your Node.js app should now be running.
By combining Claude Code with the Docker MCP Toolkit, Docker Desktop, and the Docker Hub MCP server, you can describe your stack in natural language and let MCP handle the details. This removes context switching and replaces it with a smooth, guided workflow powered by model context protocol integrations.
The future of development is not about switching between tools. It is about tools working together in a simple, safe, and predictable way. The Docker MCP Toolkit brings that future into your everyday workflow.