简体   繁体   中英

Docker container runs locally but fails on Cloud Run

I moved project from PIP to Poetry and my Docker container failed to run on Google Cloud Run.

Last string in Docker:

CMD ["poetry", "run", "uwsgi", "--http-socket", "0.0.0.0:80", "--wsgi-file", "/server/app/main.py", "--callable", "app", "-b 65535"]

It's works locally, it's works on other laptop, it's works in Cloud Run Emulator, but fails when I try to run it on Cloud Run.

Here is a Cloud Run log:

Creating virtualenv my-project-xTUGyw3C-py3.8 in /home/.cache/pypoetry/virtualenvs

FileNotFoundError

[Errno 2] No such file or directory: b'/bin/uwsgi'

at /usr/local/lib/python3.8/os.py:601 in _execvpe
597│ path_list = map(fsencode, path_list)
598│ for dir in path_list:
599│ fullname = path.join(dir, file)
600│ try:
→ 601│ exec_func(fullname, *argrest)
602│ except (FileNotFoundError, NotADirectoryError) as e:
603│ last_exc = e
604│ except OSError as e:
605│ last_exc = e
Container called exit(1).

It's have correct port set. It's doesn't use any environment variables. I don't use volumes, files passed to Docker through COPY.

Logs says that application can't find uwsgi file. That file doesn't exists in local version too, but it's works without any errors.

How that even possible that a docker container behaves differently?

UPD: My Docker file

FROM python:3.8
WORKDIR server
ENV PYTHONPATH $PYTHONPATH:/server
RUN pip install poetry==1.1.11
COPY poetry.lock /server
COPY pyproject.toml /server
RUN poetry install
EXPOSE 80
COPY /data /server/data
COPY /test /server/test
COPY /app /server/app
CMD ["poetry", "run", "uwsgi", "--http-socket", "0.0.0.0:80", "--wsgi-file", "/server/app/main.py", "--callable", "app", "-b 65535"]

adding HOME=/root to the CMD, fixed the problem for me.

CMD HOME=/root poetry run python main.py

Apparently home is not set correctly and this is a known issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM