Original Reddit post

Yesterday I discovered I was running over 60 Docker containers, all using the same Postgres MCP image. It turns out my MCP config was spinning up a new container every time I started a Claude Code session, but it was never stopping them. Here’s what my MCP config looked like: { “mcpServers”: { “my-database”: { “command”: “docker”, “args”: [“run”, “-i”, “–rm”, “-e”, “DATABASE_URI”, “crystaldba/postgres-mcp”, “–access-mode=restricted”], “env”: { “DATABASE_URI”: “postgresql://user:${DB_PASSWORD}@host:5432/db” } } } } When CC exited, it killed the docker run process. But the container is managed by the Docker daemon, which was never told to stop the container. I fixed this by switching to uvx instead of Docker. Now when CC exits, it correctly cleans up after itself. { “mcpServers”: { “my-database”: { “command”: “uvx”, “args”: [“postgres-mcp”, “–access-mode=restricted”, “postgresql://user:${STAGING_DB_PASSWORD}@host:5432/db”] } } } Blog post with more details submitted by /u/robertgambee

Originally posted by u/robertgambee on r/ClaudeCode