Skip to content

Bug: Docker container fails to start due to incorrect CMD path in Dockerfile #30

Description

@dectecx

Hi there,

Thank you for this project!

I found a small bug in the Dockerfile that prevents the container from starting correctly.

What is the bug?

When building and running the container using the provided Dockerfile, the container fails to start.

How to reproduce

  1. docker build -t mssql-mcp .
  2. docker run mssql-mcp

Error

The container exits immediately with a ModuleNotFoundError:
/usr/local/bin/python: No module named mssql_mcp_server

Analysis (The "Why")

This happens because:

  1. The WORKDIR is set to /app.
  2. The COPY . . command copies the project structure, so the main module is at /app/src/mssql_mcp_server.py.
  3. The CMD is written as ["python", "-m", "mssql_mcp_server"].

When this CMD runs, Python looks for mssql_mcp_server inside the /app directory, but it can't find it (it's one level deeper, inside src).

Suggested Fix

The root cause is that the CMD instruction doesn't account for the module being inside the src directory. Here are two possible fixes:


Option 1: Update CMD (Simpler)

Directly update the CMD to use the full module path from the WORKDIR (/app).

Change this:

CMD ["python", "-m", "mssql_mcp_server"]

To this:

CMD ["python", "-m", "src.mssql_mcp_server"]

This ensures Python (using the -m flag) correctly searches from /app, finds the src package, and then the mssql_mcp_server module inside it.


Option 2: Use PYTHONPATH Environment Variable

Alternatively, add the src directory to Python's module search path using an environment variable.

Add this line before the CMD:

ENV PYTHONPATH=/app/src

The Dockerfile end would look like this:

WORKDIR /app
ENV PYTHONPATH=/app/src
CMD ["python", "-m", "mssql_mcp_server"]

This tells Python to also look inside /app/src when searching for modules, so it can find mssql_mcp_server directly.

I hope this helps!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions