Skip to content

�� [DOCUMENTATION/BUG] Missing port mapping for FastAPI service in docker-compose.yaml #503

@evmparser

Description

@evmparser

Description

The fastapi service defined in docker-compose.yaml does not have a ports section to map the container's port (8080, as defined in Dockerfile.webserver) to a host port. This makes the FastAPI service inaccessible from the host machine.

Location

docker-compose.yaml - fastapi service definition

Severity

⚠️ MEDIUM - Prevents local development and testing of the API.

Impact

  • API is inaccessible: Developers cannot interact with or test the FastAPI service when running via Docker Compose
  • Poor developer experience: Confusing for new contributors who expect the API to be accessible
  • Testing limitations: Cannot run integration tests against the API locally
  • Documentation mismatch: If documentation mentions accessing the API, it won't work as described

Current Configuration

services:
  fastapi:
    build:
      context: .
      dockerfile: Dockerfile.webserver
    environment:
      - SOME_ENV_VAR=value
    # ❌ Missing ports section!

Expected Behavior

When running docker-compose up fastapi, developers should be able to access the API at http://localhost:8080.

Actual Behavior

The FastAPI service runs inside the container but is not accessible from the host machine. Attempting to access http://localhost:8080 results in a connection refused error.

Steps to Reproduce

  1. Run docker-compose up fastapi
  2. Try to access the API: curl http://localhost:8080
  3. Connection fails because port is not mapped
  4. Check running containers: docker ps shows the container but no port mapping

Proposed Solution

Add a ports section to the fastapi service definition:

services:
  fastapi:
    build:
      context: .
      dockerfile: Dockerfile.webserver
    ports:
      - "8080:8080"  # Map host port 8080 to container port 8080
    environment:
      - SOME_ENV_VAR=value

Alternative Solutions

Option 1: Use a different host port

If port 8080 is commonly used, consider mapping to a different host port:

ports:
  - "8000:8080"  # Access API at localhost:8000

Option 2: Document the intended usage

If the FastAPI service is only meant to be accessed by other containers in the Docker network, add a comment explaining this:

fastapi:
  # Note: This service is only accessible within the Docker network
  # Other services can access it at http://fastapi:8080
  build:
    context: .
    dockerfile: Dockerfile.webserver

Additional Context

The Dockerfile.webserver runs the application on port 8080:

CMD ["opentelemetry-instrument", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8080"]

This port needs to be exposed in docker-compose.yaml for local development.

Verification

After applying the fix, verify with:

# Start the service
docker-compose up fastapi

# In another terminal, test the API
curl http://localhost:8080/docs  # Should show FastAPI docs
curl http://localhost:8080/health  # Should return health status

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions