Which Dependencies File Should I Use for my Dockerfile?

474 Views Asked by At

I'm currently learning about Docker. I'm trying to use it in my python project (I'm using Django)

In my Dockerfile, I want my image to install the dependencies of my project into each new container. I just created a requirements.txt file using the command tool 'pipreqs'

After looking at the content of this file, I realize that I have 2 others files related to the dependencies:

  • Pipfile
  • Pipfile.lock

I think they have been created and updated when I was using pipenv command.

My question is : Which one of these file should I use in my Dockerfile? Pipfile, Pipfile.lock or requirements.txt?

1

There are 1 best solutions below

0
andrey.s On

Default choice is requirements.txt with pinned versions.

Versions can be pinned by pip freeze > requirements.txt or pipenv lock -r > requirements.txt. You need Pipfile and Pipfile.lock if you going to use pipenv inside container. Then pipenv install will use your Pipfile.lock.