Install package

2 snippets across 2 stacks — Docker, Python

Also written as install packages

DKDocker

RUN — Execute Build Commands

DK · Dockerfile
syntax
RUN <command>
RUN ["executable", "arg1", "arg2"]
example
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir -r requirements.txt

Note Each RUN creates a new image layer. Combine related commands with && to reduce layers and image size. Always clean up package manager caches in the same RUN statement, or the cache ends up in a previous layer and is never actually removed.

PYPython

pip & Dependency Management

PY · Modules & Imports
syntax
pip install package
pip install -r requirements.txt
example
# Install a package
# pip install requests

# Install specific version
# pip install requests==2.31.0

# Install from requirements file
# pip install -r requirements.txt

# Show installed packages
# pip list

# Show details about a package
# pip show requests

Note Consider using pip-tools, poetry, or uv for reproducible dependency management. pip freeze captures transitive deps, which can be fragile across platforms.