MCP · Lesson 77 of 120
Docker for MCP
A container.
A container bundles the server with everything it needs. It runs the same on a laptop, or a cloud server. That's ideal for HTTP servers.

- Everything bundled
- Runs anywhere
- Great for HTTP
Dockerfile
We start from a slim Python image, and install the MCPSDK. We copy in the server. Expose documents the port. And the command starts the server.
Dockerfiledockerfile
FROM python:3.13-slim
WORKDIR /app
RUN pip install --no-cache-dir "mcp>=2.3"
COPY northwind.py .
EXPOSE 8000
CMD ["python", "northwind.py"]northwind.py
Inside a container, the server must listen on all addresses, not just localhost. Otherwise, nothing outside the container can reach it.
northwind.pypython
if __name__ == "__main__":
mcp.run(transport="streamable-http", host="0.0.0.0", port=8000)terminal
Build the image, and run it with the port published. The server is then at localhost eight thousand, slash MCP. For a standard IO server, run the container with dash i, and give that command to the host.
terminalpython
docker build -t northwind-mcp .
docker run -p 8000:8000 northwind-mcp
# a stdio server in a container, for a host config:
# command: docker args: ["run", "-i", "--rm", "northwind-mcp"]Summary
Containers bundle your server, and run it anywhere. Listen on all addresses inside them. Next, the deployment quiz.
Key takeaways- Dockerfile
- host 0.0.0.0
- docker run -i
Next up: Deployment Quiz — test yourself