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


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)


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 .


pipenv install 

in your project folder


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


Be careful when using Docker bind mounts!

Summary: In my case, I was using bind mounts in my dev environment, and mounting a docker bind mount on a non-empty directory would overwrite the contents of the container’s directory, removing the Pipfile and Pipfile.lock, which showed the error mentioned when running the container.


Directory structure on the host

> ls project/
docker-compose.yml Dockerfile Pipfile Pipfile.lock app/


My Dockerfile would copy the contents of the project and then install the dependencies with pipenv, like this:

FROM python:3.8
# ...
COPY Pipfile Pipfile.lock /app/
RUN pipenv install --deploy --ignore-pipfile
COPY ./app /app/
CMD ["pipenv", "run", "uvicorn", "etc..", "--reload"]

Pipfile, Pipfile.lock and the code of ./app would all be in the same /app directory inside the container.


I wanted uvicorn to hot-reload, so I mounted the code in /app inside the container’s /app directory.

   - type: bind
     source: ./app
     target: /app

This meant that when I changed the code in /app, the code in the container’s /app directory would also change.


The side effect of this bind mount is that the content mounted on /app "obscured" the content previously copied in there.

Container’s content with the bind mount:

> ls app/
code1.py code2.py

Container’s content without the bind mount:

> ls app/
Pipfile Pipfile.lock code1.py code2.py


Either make sure that you include the Pipfile and Pipfile.lock as well when mounting the bind mount, or make sure that you COPY these 2 files to a directory that won’t get overwritten by a bind mount.

Leave a comment