Create a Docker Container using Cursor

Create a PostgreSQL Docker container using natural language in Cursor.

Introduction

⚑️ 30 Second Summary

Have you wondered how modern data engineering teams use AI to containerize real-world databases?

In this project, you'll create a PostgreSQL Docker container using natural language in Cursor, powered by Docker MCP (Model Context Protocol).

What You'll Build

A running PostgreSQL database container, created and managed entirely through Cursor's AI chat using the Docker MCP.

By the end of this project, you'll have:

  • βš™οΈ Docker Desktop and Cursor installed and ready to go.
  • πŸ”Œ Docker MCP connected to Cursor, giving Cursor the power to control Docker.
  • 🐘 A running PostgreSQL container created with a single chat prompt.
  • πŸ’Ž Secret Mission: Check out your container logs using Cursor prompts.

Want a complete demo of how to do this project, from start to finish? Check out our 🎬 walkthrough with Maya

Are there any prerequisites?

Not at all. No prior experience with Docker, databases, or MCP is needed.

Not sure if this project is right for you? Check if it matches your goals

If you're up for a bit of a challenge, quiz yourself on the key concepts up ahead in this project.

Get Your Tools Ready

To create our container using AI, we need two tools: Cursor, an AI-powered code editor that will let us control Docker through natural language, and Docker Desktop for running our container.

In this step, we'll install both Cursor and Docker Desktop. Let's get into it.

In this step, get ready to:

  • Install Cursor.
  • Install Docker Desktop to run containers.

Set Up Cursor

We will be prompting Cursor's AI functionality to create a Docker container with a PostgreSQL database. So let's make sure we have Cursor ready to go.

I already have Cursor downloaded

  • Open Cursor from your Applications folder (Mac) or Start menu (Windows).
  • Wait for Cursor to fully launch.
  • If prompted to update, go ahead and update to the latest version.

Onwards! Let's login.

I don't have Cursor yet

🍎 macOS

  • Download the macOS installer
Not sure what to choose?

On a Mac you may need to know your chip architecture (e.g., Apple Silicon, Intel) to select the correct version.

You can find this by selecting the Apple Menu > About This Mac.

πŸ–ΌοΈ Windows

  • Download the Windows installer.
  • Once the download is complete, open your Downloads folder.
  • Click the CursorUserSetup...exe file.
  • You might see a security warning since it's an app downloaded from the internet. This is normal!
  • Select Run to proceed.
  • The setup wizard will start.
  • Accept the license agreement.
  • Select Next.
  • Choose the destination location for the installation. The default is usually fine.
  • Select Next.
  • Choose the Start Menu folder. Again, the default is fine.
  • Select Next.
  • In the Select Additional Tasks screen, we recommend keeping the default options checked:
    • Register Cursor as an editor for supported file types
    • Add to PATH
  • Select Next.
  • You're now ready to install.
  • Select Install.

🍎 macOS

  • Once the download is complete, open your Downloads folder.
  • Click the Cursor .dmg file.
  • Then, drag the Cursor application into your Applications folder to complete the installation.
  • Open your Applications folder.
  • Click on the Cursor icon to open it.
  • You might see a security warning since it's an app downloaded from the internet. This is normal!
  • Select Open to proceed.

Nice! You've successfully installed Cursor.

πŸ–ΌοΈ Windows

  • Once the installation is complete, ensure Launch Cursor is checked.
  • Select Finish.

Nice! You've successfully installed Cursor.

I'm already logged in

Awesome, you're all set to continue!

I already have a Cursor account

Fantastic! This will be speedy.

  • Select Log In.

Your browser will open to the Cursor login page.

  • Log in to your existing Cursor account.

You should see a Welcome to Cursor page.

Awesome! You've logged in and are ready to go.

New to Cursor!

  • When Cursor launches for the first time, you'll see a welcome screen.
  • Select Sign up.
  • Your browser will open to the Cursor login page.
  • Select Sign up at the bottom of the screen to create a new account.
  • Create a new account using your email or a social provider like Google or GitHub.
  • Let's fill in your details to create the account!
  • You'll need to verify your email address.
  • Check your inbox for an email from Cursor.
  • Enter the verification code.
  • After creating your account, Cursor will ask if it can log you into its desktop app.
  • Select Yes, Log In to connect your account to the Cursor desktop app.
  • Cursor will now guide you through some setup instructions. This should only take a few minutes!
  • Select skip and continue for importing settings from VS Code (although you're welcome to import them if you use already use VS Code!)
  • Next, customize your theme.
  • Select Continue.
  • Set your preferred keybindings. VS Code is the default.
  • Select Continue.
  • You'll also see Cursor's Data Sharing agreement. By default, Cursor learns from your code. You can disable this by enabling Privacy mode via Cursor settings.
  • Check the box to proceed.
  • Select Continue.
  • Finally, review your settings.
  • Select Continue.

Awesome! You've logged in and are ready to go.

Install Docker Desktop

Instead of installing PostgreSQL directly on our operating system, we'll use Docker Desktop to run a PostgreSQL container, keeping our system clean and making it easy to start, stop, or delete the database.

Docker Desktop provides everything you need to run Docker containers on your computer.

What is Docker and Docker Desktop?

Docker is a tool that lets you package an application (like PostgreSQL) together with everything it needs to run into a lightweight bundle called a container. A container packages an app with everything it needs to run, and keeps it separated from other apps on the same machine.

Docker Desktop is the app that makes it easy to run those containers on your laptop. It includes the Docker engine, a graphical dashboard, and all the background services needed to run containers on your computer.

First, let's check if you already have Docker Desktop installed.

🍎 macOS

  • Open Terminal.
  • Run the following command:
docker --version

πŸͺŸ Windows

  • Open PowerShell.
  • Run the following command:
docker --version

βœ”οΈ I see a version number

Perfect! That should mean Docker Desktop is already installed. Now let's make sure it's running.

  • Open Docker Desktop from your Applications folder (Mac) or Start menu (Windows).

Hmm, I don't have Docker Desktop

Aha! That means we will still need to download Docker Desktop after all. It's possible for your terminal to show a docker version, but not have Docker Desktop if it was installed, and later deleted, in the past.

Make sure to switch over to the β“§ Command not found tab and check out the steps for installing Docker Desktop.

  • Wait for Docker to fully start (the whale icon should be steady, not animated).

You should see the Docker Desktop dashboard:

β“§ Command not found

Perfect! Docker isn't installed yet. Let's get it set up. 🐳

Now download the correct installer for your system:

🍎 macOS

Select the correct download for your Mac

  • If you have Apple Silicon (M1, M2, or M3), select Download for Mac - Apple Chip.
  • If you have Intel, select Download for Mac - Intel Chip.
I don't know what version I should download for my Mac!

First, let's check what type of Mac you have.

  • Click the Apple logo in the top right of your display.
  • Select About This Mac.
  • If you see Apple M1, Apple M2, or Apple M3 under Chip, you have Apple Silicon.
    • Select Download for Mac - Apple Chip.
  • If you see Intel Core, you have an Intel Mac.
    • Select Download for Mac - Intel Chip.

Install Docker Desktop

  • Open the Docker.dmg file from your Downloads folder.
  • Drag the Docker icon to your Applications folder.
  • Open Docker from your Applications folder.
Why open Docker Desktop?

Opening Docker Desktop starts the Docker service in the background. This service needs to be running for any Docker commands to work. You'll see a whale icon in your menu bar when Docker is running.

  • Click Open at the security warning.

You may see a Docker Subscription Service Agreement screen.

  • Click Accept.

You'll see a configuration screen to finish setting up Docker Desktop.

  • Keep Use recommended settings selected (the default option).
  • Click Finish.
What are recommended settings?

Recommended settings usually include turning on the right virtualization backend for your OS, setting up file sharing so containers can read and write files from key folders on your machine, and giving Docker reasonable CPU and memory limits so it doesn't overwhelm your laptop. For most developers, these defaults are safe and work well out of the box, and you can always fine-tune them later in Settings if you notice Docker is using too many resources or you want to share different folders.

Docker may prompt for your password to apply these configurations.

  • Enter your password and click OK.

You'll see a Welcome to Docker screen.

  • Click Skip in the top right.

You should now see the Docker Desktop dashboard!

Now let's verify Docker is working!

  • Open Terminal on your Mac.
  • Run this command:
docker --version
What should I see?

You should see something like Docker version 29.2.0, build afdd53b. The version and build ID on your computer will probably be different. That's totally expected and your Docker will work just the same. Why are version numbers different?

Perfect! Docker is installed and working on your Mac.

πŸͺŸ Windows

Download Docker Desktop for Windows

  • Click Download for Windows 10/11 (64-bit)

While we wait for the download, let's check if WSL 2 is installed (required for Docker Desktop).

Docker Desktop on Windows requires WSL 2 (Windows Subsystem for Linux 2). Let's check if you have it installed.

  • Right-click the Start menu.
  • Select Windows PowerShell.
  • Run the following command to check if WSL 2 is installed:
wsl --version
βœ”οΈ I see WSL version info

Nice! WSL 2 is already installed.

β“§ Command not found or error

No WSL yet? No problem, we just need to install it first.

  • Right-click the Start menu.
  • Select Windows Terminal (Admin).
  • Run the following command to install WSL 2:
wsl --install
What does wsl --install do?

This command installs WSL 2 and the default Ubuntu Linux distribution. WSL 2 is a lightweight Linux environment that runs inside Windows, which Docker Desktop uses to run Linux containers.

  • Wait for the installation to complete (this may take 5-10 minutes).
  • Restart your computer when prompted or when the installation completes.
  • After restarting, verify WSL 2 is installed by running wsl --version in PowerShell.
Still having WSL 2 issues?

If you continue to have problems installing WSL 2, you may need to:

  1. Enable virtualization in your BIOS settings.
  2. Make sure Windows is up to date. Open Settings, then select Windows Update.
  3. Share your error message with the NextWork community.

Install Docker Desktop

Let's install Docker Desktop!

  • Locate the Docker Desktop Installer.exe in your Downloads folder.
  • Double-click it to start the installation.

You'll see a security warning: "Open File - Security Warning".

  • Click Run.

You might be prompted: "Do you want this app to make changes to your device?"

  • Click Yes.

On the configuration screen, you'll see a checkbox for "Add shortcut to desktop" (optional).

  • Click OK.
Pro tip

The desktop shortcut makes it easy to open Docker Desktop later, but you can also find it in your Start menu.

Docker will now begin "Unpacking files".

What's Docker unpacking?

Docker Desktop is installing its core components: the Docker Engine (runs containers), Docker CLI (command-line tools), and desktop interface. It's also setting up the virtualization layer that lets containers run on Windows using WSL 2.

When unpacking is complete, you'll see "Installation succeeded" with a message that Docker Desktop is installed.

  • Click Close.

If you see a "Restart required" popup, restart your computer when you're ready.

  • Click Restart to complete the installation.
Why restart?

Docker Desktop needs to install system-level components and drivers. The restart ensures these components are properly loaded before you start using Docker.

After restarting, you'll need to open Docker Desktop.

  • Open Docker Desktop from your Start menu.

You'll see a Welcome to Docker screen asking you to sign in.

  • Click Skip in the top right corner.

You should now see the Docker Desktop dashboard!

Why open Docker Desktop?

Opening Docker Desktop starts the Docker service in the background. This service needs to be running for any Docker commands to work. You'll see a whale icon in your system tray when Docker is running.

Now let's verify Docker is working!

  • Open PowerShell on your Windows computer.
  • Run this command:
docker --version
What should I see?

You should see something like Docker version 24.0.7, build afdd53b. The version and build ID will likely be different on your computer. This is normal and doesn't affect functionality. Why are version numbers different?

Perfect! Docker is installed and working on your Windows machine.

Wait! βœ‹ Let's double-check Docker Desktop is running

Quick check before we move on - Docker Desktop needs to be running for the next steps to work:

  • Look for the whale icon 🐳 in your menu bar (Mac) or system tray (Windows).
  • Don't see it? Open Docker Desktop from your Applications folder (Mac) or Start menu (Windows).

Why check this?

Docker commands won't work unless Docker Desktop is running in the background. The whale icon is your visual confirmation that everything is ready to go!

Woohoo! You now have Cursor and Docker ready to go. Next up, you'll connect them with MCP so Cursor can actually control Docker!

Set Up the Docker MCP

Now that we have Cursor and Docker Desktop installed, we need is a way for Cursor to actually talk to Docker.

That's where MCP (Model Context Protocol) comes in. Right now, Cursor can only read and edit files. But if we want it to create Docker containers using AI, we need to give it that power. So let's set up our Python-based Docker MCP server.

In this step, get ready to:

  • Install Python and uv, a fast Python package manager.
  • Enable the Docker MCP in Cursor.
  • Verify the Docker MCP is connected.

What's MCP? How is it different from just using Cursor's chat?

MCP (Model Context Protocol) is a standard that lets AI models connect to external tools and services. Unlike regular Cursor chat which can only read and edit files, when you use MCP servers, Cursor can:

  • Create and control Docker containers
  • Manage infrastructure through natural language

This means you can control real infrastructure and services directly from Cursor's chat, rather than just editing code files.

Install Python

Alright, let's first check if we have Python for our MCP.

  • Go back to your Terminal (Mac) or PowerShell (Windows).
  • Run this command to check Python's version number:

🍎 macOS

python3.13 --version

πŸ–ΌοΈ Windows

py -3.13 --version

βœ”οΈ I see Python 3.13.x

Wait! I see 3.13.x - my last number is different.

That's totally fine. As long as the first few numbers read 3.13, then you have the right version.

Python 3.13 is installed and ready to use! You're all set to continue.

β“§ I see 'command not found' or an error

No worries! Python isn't installed yet.

Let's install it:

Why Python 3.13?

We're using Python 3.13 for this project because it has full compatibility with all the packages we need. Some packages haven't been updated to support newer packages like 3.14 yet, which would cause some gnarly errors as we build and test our project!

  • In the Files section, download the installer for your operating system:

🍎 macOS

  • Select Download macOS installer.

The installer file will download to your Downloads folder.

  • Open Finder (the blue and white face icon in your Dock).
  • Click Downloads in the left sidebar (or press Cmd + Option + L to open Downloads).
  • Look for the downloaded file named python-3.13.11-macos11.pkg (or similar with a version number).
  • Double-click the .pkg file to open the installer.
What is a .pkg file?

A .pkg file is a macOS installer package. When you double-click it, macOS opens the installation wizard that guides you through installing Python on your computer.

  • The Python installer window will appear. Click Continue.
  • Click Continue again on the Install Python screen.
  • Read the license agreement and click Continue.
  • Click Agree to accept the license terms.
  • Click Continue.

The installer will show you where Python will be installed (usually /Applications).

  • Click Install.
  • Click Close to finish.

πŸ–ΌοΈ Windows

  • Look for the Windows section and click Download Python install manager, which uses Windows installer (64-bit). This is the recommended version for most Windows computers.
What's the difference between 64-bit and 32-bit?

Think of 64-bit and 32-bit like different sizes of containers for processing information:

  • 64-bit systems can handle larger amounts of data at once - like having a bigger container that can hold more items. Most modern computers (from around 2005 onwards) use 64-bit processors because they're faster and can use more memory (RAM).
  • 32-bit systems use smaller containers and can only handle limited amounts of data. These were common on older computers but are rarely used today.

πŸ’‘ Which one should I choose?

Almost everyone should choose 64-bit - it's what 99% of modern Windows computers use. Only choose 32-bit if you have a very old computer (from before 2005) that specifically requires it. If you're unsure, 64-bit is almost always the right choice!

  • Run the downloaded installer.
  • Follow the installation wizard, making sure to check Add Python to PATH during installation.
  • Click Install Now and wait for installation to complete.

Verify your installation

Great! Python should now be installed on your computer. Let's verify that everything worked correctly!

  • Head back into your terminal (the same terminal window you used earlier, or open a new one if you closed it).
  • Verify Python by running the version command again:

🍎 macOS

python3.13 --version

πŸ–ΌοΈ Windows

py -3.13 --version

You should now see a Python version number like Python 3.13.11.

Still stuck?

Get help with your error or share your error with the NextWork community!

Do we need Python for all MCPs?

No, Python is not a requirement for all MCPs. Python is considered the "native tongue" of AI and data, so many early and popular MCP servers, like the Docker MCP we'll be setting up, are built using Python.

Install uv Package Manager

We've got Python installed, but to run the Docker MCP, we also need a way to install and manage Python packages. That's where uv comes in.

First, let's check if you already have uv installed.

  • In Cursor's terminal, run the following command:
uv --version

What is uv?

uv is a modern Python package manager that's 10-100x faster than traditional tools like pip (it's written in Rust, a compiled language, which makes it blazingly fast).

βœ”οΈ I see a version number

Great, it looks like uv is already installed!

Do you have an old version of uv?

If your version is below 0.4.0, consider updating uv by running the installation command again - it will update your existing installation.

β“§ Command not found

No worries! uv isn't installed yet. Let's get it running.

🍎 macOS

  • Run the following command in your terminal:
curl -LsSf https://astral.sh/uv/install.sh | sh
What does this command do?

The command curl -LsSf https://astral.sh/uv/install.sh | sh downloads and runs the uv installer:

  • curl -LsSf downloads the uv installer script from astral.sh
  • | (pipe) passes it to the next command
  • sh executes the script. It's like downloading a file and running it in one step.

πŸ™‹β€β™€οΈ Command not found after installation?

If you get a "command not found" error after installation, you need to add uv to your PATH.

Run uv --version again to verify:

Still seeing errors? Share them with the NextWork community!

πŸ’‘ Note: You may need to restart your terminal for the uv command to be recognized.

Now verify the installation worked:

uv --version

You should see a version number like uv 0.4.18 - perfect, uv is installed!

πŸ–ΌοΈ Windows

In Cursor's terminal at the bottom of the window, run the following command:

iwr https://astral.sh/uv/install.ps1 -UseBasicParsing | iex
What does this command do?

The command iwr https://astral.sh/uv/install.ps1 -UseBasicParsing | iex downloads and runs the uv installer:

  • iwr (Invoke-WebRequest) downloads the uv installer script from astral.sh
  • | (pipe) passes it to the next command
  • iex (Invoke-Expression) executes it. It's like downloading a file and running it in one step.

Wait for the installation to complete (usually 10-20 seconds).

I got an execution policy error!

If you see an error about execution policies, you need to allow PowerShell to run scripts:

  1. Close your current terminal
  2. Open a new terminal as Administrator (right-click your IDE β†’ Run as administrator)
  3. Run: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
  4. Type Y and press Enter
  5. Try the uv installation command again

Still getting errors? Share your error message with the NextWork community!

πŸ’‘ Note: You may need to restart your terminal for the uv command to be recognized.

Now verify the installation worked:

uv --version

You should see a version number like uv 0.4.18 - perfect, uv is installed!

Enable the Docker MCP in Cursor

Now comes the magic - we'll tell Cursor about our Docker MCP server by adding it to a configuration file.

  • Click the settings icon (gear icon) in the top right of Cursor.
  • Select Tools & MCP from the left-hand side settings menu.
  • Scroll down.
  • Click "Add Custom MCP" (or "New MCP Server" if you already have MCPs configured).

Button says "New MCP Server"?

If you already have other MCP servers configured in Cursor, the button will say "New MCP Server" instead of "Add Custom MCP". This is perfectly normal - just click it to add another MCP server!

The file: mcp.json will open showing your Cursor MCP configurations. We'll add a Docker MCP to your configuration.

My mcp.json is empty

If your mcp.json file looks like this (empty), just drop in the complete configuration below based on your operating system:

🍎 macOS/Linux

Add this to your mcp.json:

{
  "mcpServers": {
    "docker": {
      "command": "uv",
      "args": ["run", "--with", "docker-mcp", "docker-mcp", "--access-mode=unrestricted"],
      "env": { "DOCKER_HOST": "unix:///var/run/docker.sock" }
    }
  }
}

πŸ–ΌοΈ Windows

Add this to your mcp.json:

{
  "mcpServers": {
    "docker": {
      "command": "uv",
      "args": ["run", "--with", "docker-mcp", "docker-mcp", "--access-mode=unrestricted"],
      "env": { "DOCKER_HOST": "npipe:////./pipe/docker_engine" }
    }
  }
}

I already have MCP servers configured

Add these two individual server blocks to your existing mcpServers section.

First, add the Docker MCP based on your OS:

🍎 macOS/Linux

Add this to your mcp.json:

"docker": {
  "command": "uv",
  "args": ["run", "--with", "docker-mcp", "docker-mcp", "--access-mode=unrestricted"],
  "env": { "DOCKER_HOST": "unix:///var/run/docker.sock" }
}

πŸ–ΌοΈ Windows

Add this to your mcp.json:

"docker": {
  "command": "uv",
  "args": ["run", "--with", "docker-mcp", "docker-mcp", "--access-mode=unrestricted"],
  "env": { "DOCKER_HOST": "npipe:////./pipe/docker_engine" }
}

Hint: Don't forget to add a comma!

When adding the Docker MCP to your existing mcp.json, make sure there's a comma (,) after the closing brace of your previous MCP server entry. JSON requires commas to separate objects.

Also pay careful attention to the proper nesting and structure - see the example below showing correct comma placement and formatting:

Excellent! Now save the file.

  • Press Cmd + S (Mac) or Ctrl + S (Windows/Linux).

What does this configuration do?

This JSON file tells Cursor how to run MCP servers:

  • command - The program to execute (we use uv to run Python packages)
  • args - Arguments passed to the command (tells uv which MCP package to run)
  • env - Environment variables like connection strings and socket paths

Reload Cursor

For Cursor to pick up the new MCP server, we need to reload the window.

  • Press Cmd + Shift + P (Mac) or Ctrl + Shift + P (Windows) to open the Command Palette.
  • Type Reload Window.
  • Select Developer: Reload Window.

Why reload?

MCP configurations are loaded when Cursor starts. Reloading the window refreshes Cursor so it reads your new configuration and connects to the Docker MCP server.

Now let's verify the MCP servers connected successfully.

  • Click the settings icon (gear icon) in the top right.
  • Select MCP from the left sidebar.
  • Look for docker with green indicators showing they're connected.

βœ”οΈ Docker MCP is green

You're all set! Your Docker MCP server is connected and ready to go.

β“§ Docker MCP isn't green

Don't worry - this is usually a configuration issue. Let's troubleshoot it.

  • Is your Docker Desktop is running?
  • Did you reload your Cursor? Try restarting the Cursor application.
  • Have you double-checked your MCP configuration for typos?

βœ”οΈ Yes, it's green now

Nice work! You're all set.

β“§ Still not green

Do you see a Python version error?

The docker-mcp package requires Python 3.12 or higher, and if uv is using an older version (like Python 3.11), the MCP server will fail to start.

To fix this, add a UV_PYTHON entry to the env section of your Docker MCP config in mcp.json:

"docker": {
  "command": "uv",
  "args": ["run", "--with", "docker-mcp", "docker-mcp", "--access-mode=unrestricted"],
  "env": {
    "DOCKER_HOST": "unix:///var/run/docker.sock",
    "UV_PYTHON": "/opt/homebrew/bin/python3.12"
  }
}

This tells uv to use Python 3.12 specifically when running docker-mcp. After updating, reload Cursor's window again and check MCP settings.

Still stuck?

Get help with your error or share your error with the NextWork community!

Now let's do a quick test to make sure everything is working end-to-end.

  • Open Cursor's AI Chat pane (Cmd + L (macOS) or Ctrl + L (Windows)).
  • Send this prompt:
Using the Docker MCP, tell me what Docker containers do I have on my system?

Cursor will use the Docker MCP tools to query your Docker environment. You'll see tool calls appear in the chat.

  • Click Allowlist MCP tool to allow them for all future instances, or just click Run to allow it once.

Since we haven't created any containers yet, Cursor should report back that you have no Docker containers on your system (unless you already have containers!).

Nice - the Docker MCP is connected and working. Let's find out what else can we do with our Docker MCP.

  • In a new Cursor chat, send this prompt:
Using the Docker MCP, tell me what I can do.

Great, we've already used the Docker MCP to list our containers. Now let's create your first container!

Create Your Docker Container

Instead of writing terminal commands, we'll just ask Cursor to create our PostgreSQL container for us using the Docker MCP.

In this step, get ready to:

  • Prompt Cursor to create a PostgreSQL container using the Docker MCP.
  • Verify the container is running in Docker Desktop.

Create PostgreSQL Container

  • Make sure Cursor's chat is open, then send this prompt:
Using the Docker MCP, create a new Postgres container named my-db with these settings:
- Database name: nextwork
- Username: admin
- Password: secretpass123
- Map port 5432 on the container to port 5432 on my computer

What is PostgreSQL?

PostgreSQL (often shortened to "Postgres") is a popular open‑source database. Many startups and large companies use PostgreSQL in production because it's powerful, reliable, and free.

πŸ’‘ What does this prompt do?

We are prompting Cursor (through the Docker MCP) to create a running PostgreSQL container for you using PostgreSQL's Docker image. The image looks for specific variables:

  • POSTGRES_DB: The name of the database to create on startup
  • POSTGRES_USER: The username for the database administrator
  • POSTGRES_PASSWORD: The password for that user
  • 5432:5432 : Port mapping allows any application on your computer to connect to the database at localhost:5432

Cursor will analyze your request and propose using the Docker MCP.

  • Look for a tool in the chat, something like create-container:docker.
  • Click Allowlist MCP tool to allow them for all future instances, or just click Run to allow it once.

What is a tool call?

A tool call is Cursor's way of making a structured request to an MCP server to run a specific function. When you ask Cursor to create a Docker container, it generates a tool call that says "use this MCP function (like mcp_docker_create-container) with these parameters."

Cursor shows you this tool call in the chat so you can see exactly what's about to happen before it runs.

The first time you create a PostgreSQL container, Docker needs to download the PostgreSQL image (approximately 150MB). This usually takes 2-5 minutes depending on your internet connection.

What do you see after sending the prompt?

βœ”οΈ I see tool calls appearing

Cursor is connecting to the Docker MCP and running tool calls. It'll take about 10-15 seconds for the container to start up.

You're on the right track!

β“§ Nothing is happening / I see errors

That's not right! Let's get this sorted out.

  • Make sure your Cursor chat is in Agent mode, not Ask mode. Only Agent mode can use MCP tools. Check the bottom of your chat pane for the mode selector.
  • Check the Tools & MCP page in your Cursor Settings. If the Docker MCP is showing errors, expand the entry to view the detailed error message and paste it into your Cursor chat to troubleshoot.

Still stuck?

Get help with your error or share your error with the NextWork community!

What do you see in your Cursor chat once it's done running MCP tool calls?

βœ”οΈ Container created successfully

Nice! Your PostgreSQL container is running. You should see Cursor confirm:

  • Container name: my-db
  • Image: postgres
  • Status: running
  • Port mapping: 5432:5432 (or similar port information)

β“§ Docker MCP can't connect

Don't worry, this usually just means Docker Desktop isn't running yet.

If you see an error like "The Docker MCP server can't connect to Docker" or "Failed to initialize: protocol not available", try these steps:

Make sure Docker Desktop is running

  • Look for the whale icon in your menu bar (Mac) or system tray (Windows).
  • If you don't see it, open Docker Desktop from your Applications folder or Start menu.
  • Wait for Docker Desktop to fully start (the whale icon should be steady, not animated).

Verify Docker is accessible

  • In Cursor's terminal, run:
docker ps

If this shows a list of containers (even if empty), Docker is working!

If the MCP still can't connect, create the container manually

You can create the container using the terminal instead:

docker run -d --name my-db -p 5432:5432 -e POSTGRES_DB=nextwork -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=secretpass123 postgres

Still stuck?

Get help with your error or share your error with the NextWork community!

Nice work. Let's verify it in Docker Desktop.

Verify in Docker Desktop

  • Open Docker Desktop.
  • Select Containers.

You should see my-db with a green "Running" status.

Your PostgreSQL container is running. Next up, we'll use Docker Compose to level up your container with proper configuration!

See Your Database in the Browser

You've created a PostgreSQL container, but right now you can't see inside it. To visually access your database, you need a second container running Adminer, a web interface that connects to PostgreSQL and lets you view your data in the browser.

In this step, we'll use Docker Compose to set up both PostgreSQL and Adminer, then access your database visually at localhost:8081.

In this step, get ready to:

  • Create a project folder on your Desktop.
  • Set up PostgreSQL and Adminer with Docker Compose.
  • Access your database in the browser.

Create a Project Folder

First, let's create a dedicated folder for this project to keep everything organized.

  • On Cursor, select File, then New Window.
  • Select Open project.
  • In the pop-up, navigate to the Desktop of your computer.
  • Select New Folder.
  • Name your new folder mcp-docker.
  • Select Open for your new folder.
  • Nice! You have a new, empty project ready to go.

Set Up a Web Interface for PostgreSQL

Now let's ask Cursor to set up both your database and a web interface to view it.

  • Send this prompt in your Cursor chat:
Using the Docker MCP, create a docker-compose.yml file with two containers:

1. PostgreSQL database named my-db:
   - Database name: nextwork
   - Username: admin
   - Password: secretpass123
   - Port: 5432

2. Adminer web interface:
   - Use the adminer:latest image
   - Port: 8081

Then start both containers.

Cursor will create a configuration file and start both containers. This will stop your old my-db container and create the new setup.

What is Adminer?

Adminer is a lightweight, open-source database management tool. It runs as a single web page and gives you a visual way to browse tables, run queries, and manage your database through the browser.

πŸ’‘ Why Docker Compose?

Instead of creating each container separately, Docker Compose lets you define multiple containers in one file and start them together with a single command. You're asking Cursor to create a docker-compose.yml file, a configuration that defines multiple containers to run together. Cursor will then use the Docker MCP to start everything at once.

  • Confirm Cursor created the docker-compose.yml file in the correct location.
  • You should see the docker-compose.yml file.

Access Your Database in the Browser

Now let's visually see the PostgreSQL database living in your PostgreSQL container by using Adminer.

  • Open your browser and go to:
http://localhost:8081

Shall we login and check out what is in our database?

  • Fill in the login credentials to access your database.

πŸ” Try it yourself

Hint

Check the docker-compose.yml file in your mcp-docker folder on your Desktop.

  • Click Login.

πŸ“‹ Show me the credentials

  • Log in with these credentials:
    • System: PostgreSQL
    • Server: my-db
    • Username: admin
    • Password: secretpass123
    • Database: nextwork
  • Click Login.

Woah! You're in! The nextwork database is empty - perfect! You've successfully connected two containers and can now see your data visually.

You've leveled up! Not only have you created a container with a PostgreSQL database, you've also used the Docker MCP to orchestrate multiple containers that work together.

Ready to see what's happening inside the containers? Try the Secret Mission!

Secret mission

Your container is running, but how do you know what's happening inside it? In real projects, engineers check container logs to monitor database health, catch errors, and debug issues. And now you'll use the Docker MCP to inspect your container's logs without ever opening a terminal.

πŸ’Ž In this secret mission, get ready to:

  • Use the Docker MCP to check your container's logs.
  • Understand what the log entries mean.

Check Your Container Logs

Clean Up Your Resources

Clean Up Your Resources

Now that we've set up Docker Compose with PostgreSQL and Adminer, it's time to decide what to do with the resources we created.

Resources to manage:

  • my-db Docker container (PostgreSQL database)
  • adminer Docker container (web interface)
  • mcp-docker folder on your Desktop (contains docker-compose.yml)
  • Docker Desktop application (optional)
  • Cursor application (optional)

🟒 Keep everything running

If you want to continue experimenting:

  • Your my-db and adminer containers will remain running.
  • You can access your database at http://localhost:8081 anytime.
  • Your mcp-docker folder stays on your Desktop.
  • Docker Desktop will continue running in the background.

No action needed!

🟑 Stop but keep resources

There are two ways to go about it if you want to pause but keep your setup for later:

Option 1: Use Docker Desktop

  • Open Docker Desktop.
  • Find my-db and adminer in the Containers list.
  • Click the Stop button (square icon) for each container.

Option 2: Use Terminal

docker stop my-db adminer

This stops both containers but keeps your docker-compose.yml file in the mcp-docker folder. You can restart them anytime by clicking the Start button in Docker Desktop.

πŸ”΄ Delete everything

If you're completely done with this project:

Stop and remove all containers

Option 1: Use Docker Desktop

  • Open Docker Desktop.
  • Find my-db and adminer in the Containers list.
  • Click the Stop button (square icon) for each container.
  • Click the Delete button (trash icon) for each container.

Option 2: Use Terminal

docker stop my-db adminer
docker rm my-db adminer

Delete the project folder

  • Delete the mcp-docker folder from your Desktop (contains docker-compose.yml).

Uninstall Docker Desktop (optional)

🍎 macOS

  • Open your Applications folder.
  • Drag Docker to the Trash, then empty the Trash.

πŸͺŸ Windows

  • Open Settings.
  • Select Apps, then Apps & features.
  • Find Docker Desktop and click Uninstall.

Uninstall Cursor (optional)

🍎 macOS

  • Open your Applications folder.
  • Drag Cursor to the Trash, then empty the Trash.

πŸͺŸ Windows

  • Open Settings.
  • Select Apps, then Apps & features.
  • Find Cursor and click Uninstall.

Should I uninstall Cursor or Docker?

Only uninstall if you're sure you won't use it again soon. Both Cursor and Docker are useful tools to keep and don't consume resources when not running.

That's a wrap!

That's a wrap!

You did it! You've created a PostgreSQL Docker container using nothing but natural language in Cursor.

You've learned how to:

  • βš™οΈ How MCP (Model Context Protocol) connects code editors to external tools.
  • 🐳 Docker fundamentals: containers and images.
  • 🐘 What PostgreSQL is and how it runs inside a container.
  • πŸ“¦ How Docker Compose defines repeatable container setups.
  • πŸ’¬ How to manage infrastructure by just typing what you want.
  • πŸ’Ž Checked container logs to monitor database health.

Ready to quiz yourself? πŸ’ͺ

p.s. Does it say "Still tasks to complete!" at the bottom of the screen?

This means you still have screenshots left to upload, or questions left to answer!

  1. Press Ctrl+F (Windows) or Command+F (Mac) on your keyboard.
  2. Search for the text Return to later.
  3. Jump straight to your incomplete tasks!
  4. πŸ™‹β€β™€οΈ Still stuck? Ask the community!