error running pipenv with gunicorn on docker: No such file or directory

  docker, gunicorn, python

When running gunincorn using pipenv inside docker container entrypoint, same command I can run locally without docker normally

pipenv run gunicorn -b 0.0.0.0:8000 meerkat.configurations.app.main:app -w 1 -k gevent --reload
meerkat_1  | Traceback (most recent call last):
meerkat_1  |   File "/usr/local/bin/pipenv", line 8, in <module>
meerkat_1  |     sys.exit(cli())
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 829, in __call__
meerkat_1  |     return self.main(*args, **kwargs)
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 782, in main
meerkat_1  |     rv = self.invoke(ctx)
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1259, in invoke
meerkat_1  |     return _process_result(sub_ctx.command.invoke(sub_ctx))
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
meerkat_1  |     return ctx.invoke(self.callback, **ctx.params)
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
meerkat_1  |     return callback(*args, **kwargs)
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func
meerkat_1  |     return ctx.invoke(f, obj, *args, **kwargs)
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
meerkat_1  |     return callback(*args, **kwargs)
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/cli/command.py", line 449, in run
meerkat_1  |     do_run(
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 2547, in do_run
meerkat_1  |     run_fn(*run_args, **run_kwargs)
meerkat_1  |   File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 2499, in do_run_posix
meerkat_1  |     os.execl(
meerkat_1  |   File "/usr/local/lib/python3.8/os.py", line 536, in execl
meerkat_1  |     execv(file, args)
meerkat_1  | FileNotFoundError: [Errno 2] No such file or directory
FileNotFoundError: [Errno 2] No such file or directory

Dockerfile

FROM python:3.8.11-slim-buster

ENV PYTHONUNBUFFERED 1

RUN apt-get update && apt-get install -y automake make git zsh util-linux && 
    rm -f /tmp/*

RUN pip install --upgrade pip pipenv==2020.11.15

# set working directory
RUN mkdir -p /code/
WORKDIR /code/

# add requirements
COPY Pipfile Pipfile.lock .env /code/

RUN pipenv install --dev --deploy

# add entrypoint.sh
COPY ./.docker/entrypoint.sh /code/

EXPOSE 8000

# run server
CMD ["sh", "/code/entrypoint.sh"]

Source: Docker Questions

LEAVE A COMMENT