Skip to content

BUG: Fix Dockerfile: remove --user flag from pip install (incorrect in container context) #37

Description

@DewaldOosthuizen

Summary

web/Dockerfile runs pip install --user, which installs packages into /root/.local instead of the system site-packages. When Python is invoked as python app.py (the CMD), packages installed to --user may not be on sys.path depending on the base image configuration, leading to ModuleNotFoundError at container startup.

Background

The --user flag is intended for non-root installs on shared machines where the user cannot write to system site-packages. Inside a Docker container running as root (the default), it adds unnecessary complexity and can cause import failures. The correct pattern is a plain pip install --no-cache-dir -r requirements.txt.

Affected Areas

  • web/Dockerfile line 8

Recommended Fix

# Before
RUN python3 -m pip install --user --no-cache-dir -r requirements.txt

# After
RUN pip install --no-cache-dir -r requirements.txt

Acceptance Criteria

  • --user flag removed from Dockerfile
  • docker-compose build && docker-compose up succeeds
  • curl http://localhost:5000/hello returns Hello World!

Complexity Estimate

XS — single-line Dockerfile change.

Priority

Medium — may silently work on some base images but is incorrect practice and a latent failure risk.


Auto-identified by workspace issue-logger
Category: coding standards / style / linting
Complexity: XS
Repository: DewaldOosthuizen/python_rest_tutorial

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions