bonfab
bonfab

Reputation: 302

Dockerized Python Project - Best way to manage dependencies: Dockerfile or requirements.txt

What is the best practice for handling dependencies of a dockerized python project? Would I declare all of them in the Dockerfile or in the requirements.txt?

Upvotes: 1

Views: 351

Answers (2)

adamgy
adamgy

Reputation: 5643

You can define your dependencies in a requirements.txt file, then install them with Docker:

RUN pip install -r requirements.txt

Upvotes: 3

Dupinder Singh
Dupinder Singh

Reputation: 7769

The best way to handle the dependencies is using requirements.txt

Try this dockerfile

FROM python:3.8-slim-buster
COPY . /work
WORKDIR /work
RUN apt-get update
RUN apt-get upgrade -y
RUN pip install -r requirements.txt

Upvotes: 3

Related Questions