'Docker error with pipenv on django app: Warning: --system is intended to be used for pre-existing Pipfile

When I was trying to dockerize my django app, I followed a tutorial telling me to structure my Dockerfile like this

FROM python:3.6

ENV PYTHONUNBUFFERED 1

COPY . /code/
WORKDIR /code/

RUN pip install pipenv
RUN pipenv install --system

EXPOSE 8000 

After I saved that and run docker build .

the system threw me this error

Warning: --system is intended to be used for pre-existing Pipfile 
installation,not installation of specific packages. Aborting.

I think it is complaining about the --system suffix above but the tutorial says it's crucial to have it so that my packages are applied in the entire docker container. I'm new to docker and even pipenv because I took over a previous person's code and isn't sure where their pipfile is or even if they have a pipfile. If you have any insights on how to fix this error thank you in advance.



Solution 1:[1]

pipenv --rm

This helped me! I was starting the "Django for beginners" and at the very beginning, got this error (accidently deleted Pipfile & Pipfile.lock)

Solution 2:[2]

Your warning is saying you that there is no Pipfile in your project dir.

--system is intended to be used for pre-existing Pipfile.

So before running

docker build .

run

pipenv install 

in your project folder

Solution 3:[3]

Above solution didn't work for me.

After installing in the virtual env I also had to explicitly include Pipfile and Pipfile.lock into my dockerfile:

COPY Pipfile* .
# Install dependencies
RUN pip install pipenv && pipenv install --system

Then rebuild with docker compose:

docker-compose build

You can find more info in this thread

Solution 4:[4]

It has Error in pipenv

It is ?
ERROR:: --system is intended to be used for pre-existing Pipfile installation, not installation of specific packages. Aborting.

try it

pipenv check or python3 -m pipenv check

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vadim Bulatov
Solution 2 Sardorbek Imomaliev
Solution 3 big_in_japan
Solution 4 Nick3rman